public static int copy ( Reader input , Writer output , int charCount ) throws IOException { char buffer [ ] = new char [ ioBufferSize ] ; int count = 0 ; int read ; while ( charCount > 0 ) { if ( charCount < ioBufferSize ) { read = input . read ( buffer , 0 , charCount ) ; } else { read = input . read ( buffer , 0 , ioBufferSize ) ; } if ( read == - 1 ) { break ; } charCount -= read ; count += read ; output . write ( buffer , 0 , read ) ; } return count ; }
Copies specified number of characters from reader to writer using buffer .