code: public static long copy(
                      final Reader input,
                      final Writer output
                      )
      throws IOException
      {
          _LOG_.debug( "begin copy" );
  
          @SuppressWarnings( "resource" )
          BufferedReader  b_input = (BufferedReader.class.isInstance( input )
                                      ? BufferedReader.class.cast( input )
                                      : new BufferedReader( input ));
          @SuppressWarnings( "resource" )
          BufferedWriter  b_output = (BufferedWriter.class.isInstance( output )
                          ? BufferedWriter.class.cast( output )
                          : new BufferedWriter( output ));
  
          char[]  buffer = new char[512];
          long  size = 0;
          try {
              while (true) {
                  int  n = b_input.read( buffer );
                                 //@throws IOException
                  if (n == -1) {
                      break;
                  }
                  b_output.write( buffer, 0, n );
                         //@throws IOException
                  size += n;
              }
          } finally {
              try {
                  b_output.flush();
              } catch (Exception ex) {
                  //ignorable
              }
          }
  
          _LOG_.debug( "end copy: #bytes=" + size );
          return size;
      }
docs: Reads the contents from the specified input and writes them to the output.
  In this method, the given streams are not closed.
  
  @param   input
  the input reader.
  @param   output
  the output writer.
  @return
  the total number of bytes written to the output.