public static void copyReaderToWriter ( Reader input , Writer output , boolean close ) throws IOException { try { BufferedReader in = bufferInput ( input ) ; BufferedWriter out = bufferOutput ( output ) ; int ch = in . read ( ) ; while ( ch != - 1 ) { out . write ( ch ) ; ch = in . read ( ) ; } out . flush ( ) ; out . close ( ) ; } finally { if ( close ) { input . close ( ) ; output . close ( ) ; } } }
Copies the Reader to the Writer .