code: public static Parseable newParseable(final Readable r) {
          return new Parseable() {
              CharBuffer buff = emptyBuffer();
              int unread = Integer.MIN_VALUE;
              boolean end = false;
              boolean closed = false;
  
              public void close() throws IOException {
                  closed = true;
                  if (r instanceof Closeable) {
                      ((Closeable) r).close();
                  }
              }
  
              public int read() throws IOException {
                  if (closed) {
                      throw new IOException("Can not read from closed Parseable");
                  }
                  if (unread != Integer.MIN_VALUE) {
                      int ch = unread;
                      unread = Integer.MIN_VALUE;
                      return ch;
                  }
                  if (end) {
                      return Parseable.END_OF_INPUT;
                  }
                  if (buff.position() < buff.limit()) {
                      return buff.get();
                  }
                  if (readIntoBuffer(buff, r)) {
                      return buff.get();
                  } else {
                      end = true;
                      return Parseable.END_OF_INPUT;
                  }
              }
  
              public void unread(int ch) throws IOException {
                  if (unread != Integer.MIN_VALUE) {
                      throw new IOException("Can't unread after unread.");
                  }
                  unread = ch;
              }
          };
      }
docs: Create a new {@link Parseable} wrapping the given {@link Readable}.
  
  <p>The {@link java.io.Closeable#close()} method of the
  resulting Parseable closes the {@code r} if {@code r} is itself
  Closable.
  @param r a Readable which must not be null.
  @return a Parseable over the given Readable.