question: private static void copyFile ( File src , File dst , Integer port , boolean internalCompression ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( new FileInputStream ( src ) , StandardCharsets . UTF_8 ) ) ; Writer out = new OutputStreamWriter ( new FileOutputStream ( dst ) , StandardCharsets . UTF_8 ) ; for ( String line = in . readLine ( ) ; null != line ; line = in . readLine ( ) ) { if ( null != port ) line = line . replace ( "TEST_PORT" , port . toString ( ) ) ; line = line . replace ( "COMPRESSION" , internalCompression ? "internal" : "false" ) ; out . write ( line ) ; } in . close ( ) ; out . close ( ) ; }
target:  character copy of file using UTF-8. If port is non-null, will be substituted any time "TEST_PORT" is found.