public static void copyStreamWithFilterSet ( final InputStream in , final OutputStream out , final FilterSet set ) throws IOException { final BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; final BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( out ) ) ; String lSep = System . getProperty ( "line.separator" ) ; String line = reader . readLine ( ) ; while ( null != line ) { writer . write ( set . replaceTokens ( line ) ) ; writer . write ( lSep ) ; line = reader . readLine ( ) ; } writer . flush ( ) ; }
Read the data from the input stream and write to the outputstream filtering with an Ant FilterSet .