public static char[] readCharAmountFromReader(Reader reader,int length) throws IOException {
  try {
    char[] chars=new char[length];
    int totalRead=0;
    do {
      int read=reader.read(chars,totalRead,length - totalRead);
      if (read == -1) {
        break;
      }
      totalRead+=read;
    }
 while (totalRead != length);
    return chars;
  }
  finally {
    reader.close();
  }
}

public static char [ ] readCharAmountFromReader ( Reader reader , int length ) throws IOException { try { char [ ] chars = new char [ length ] ; int totalRead = 0 ; do { int read = reader . read ( chars , totalRead , length - totalRead ) ; if ( read == - 1 ) { break ; } totalRead += read ; } while ( totalRead != length ) ; return chars ; } finally { reader . close ( ) ; } }
attempts to read given length amount of chars from given reader , and returns them in a char [ ] . closes reader afterwards .
