/** * copy character stream with given buffer size */ static void copy( Reader from, Writer to, int bufferSize ) throws IOException { char[] buffer = new char[ bufferSize ]; int bufferLen = 0; while ( ( bufferLen = from.read( buffer ) ) >= 0 ) { to.write( buffer, 0, bufferLen ); } to.flush(); }