1
2
3
4
5
6
7
8
9
10
11
/**
 * 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();
}