public static Writer createWriter ( File file ) throws NaaccrIOException { OutputStream os = null ; try { os = new FileOutputStream ( file ) ; if ( file . getName ( ) . endsWith ( ".gz" ) ) os = new GZIPOutputStream ( os ) ; return new OutputStreamWriter ( os , StandardCharsets . UTF_8 ) ; } catch ( IOException e ) { if ( os != null ) { try { os . close ( ) ; } catch ( IOException e1 ) { // give up } } throw new NaaccrIOException ( e . getMessage ( ) ) ; } }
Returns a generic writer for the provided file taking care of the optional GZ compression .