public static CharArrayWriter readAllCharsFromReader(Reader reader) throws IOException {
  try {
    final int BUFFER_SIZE=1024;
    char[] buffer=new char[BUFFER_SIZE];
    CharArrayWriter chars=new CharArrayWriter();
    int read;
    while ((read=reader.read(buffer)) != EOF) {
      chars.write(buffer,0,read);
    }
    return chars;
  }
  finally {
    reader.close();
  }
}

public static CharArrayWriter readAllCharsFromReader ( Reader reader ) throws IOException { try { final int BUFFER_SIZE = 1024 ; char [ ] buffer = new char [ BUFFER_SIZE ] ; CharArrayWriter chars = new CharArrayWriter ( ) ; int read ; while ( ( read = reader . read ( buffer ) ) != EOF ) { chars . write ( buffer , 0 , read ) ; } return chars ; } finally { reader . close ( ) ; } }
reads and returns all chars from given reader until an eof is read . closes reader afterwards .
