code: public static String read(Reader reader, int length) {
          try {
              char[] buffer = new char[length];
  
              int offset = 0;
              int rest = length;
              int len;
              while ((len = reader.read(buffer, offset, rest)) != -1) {
                  rest -= len;
                  offset += len;
  
                  if (rest == 0) {
                      break;
                  }
              }
  
              return new String(buffer, 0, length - rest);
          } catch (IOException ex) {
              throw new IllegalStateException("read error", ex);
          }
      }
docs: <p>read.</p>
  
  @param reader a {@link java.io.Reader} object.
  @param length a int.
  @return a {@link java.lang.String} object.