public static int copy(Reader in,Writer out) throws IOException {
  Assert.notNull(in,"No Reader specified");
  Assert.notNull(out,"No Writer specified");
  try {
    int byteCount=0;
    char[] buffer=new char[BUFFER_SIZE];
    int bytesRead=-1;
    while ((bytesRead=in.read(buffer)) != -1) {
      out.write(buffer,0,bytesRead);
      byteCount+=bytesRead;
    }
    out.flush();
    return byteCount;
  }
  finally {
    try {
      in.close();
    }
 catch (    IOException ex) {
    }
    try {
      out.close();
    }
 catch (    IOException ex) {
    }
  }
}

public static int copy ( Reader in , Writer out ) throws IOException { Assert . notNull ( in , "No Reader specified" ) ; Assert . notNull ( out , "No Writer specified" ) ; try { int byteCount = 0 ; char [ ] buffer = new char [ BUFFER_SIZE ] ; int bytesRead = - 1 ; while ( ( bytesRead = in . read ( buffer ) ) != - 1 ) { out . write ( buffer , 0 , bytesRead ) ; byteCount += bytesRead ; } out . flush ( ) ; return byteCount ; } finally { try { in . close ( ) ; } catch ( IOException ex ) { } try { out . close ( ) ; } catch ( IOException ex ) { } } }
copy the contents of the given reader to the given writer . closes both when done .
