code: @Override
      public boolean ready() throws IOException {
          synchronized (lock) {
              if (in == null) {
                  throw new IOException("InputStreamReader is closed.");
              }
              try {
                  return bytes.hasRemaining() || in.available() > 0;
              } catch (IOException e) {
                  return false;
              }
          }
      }
docs: Indicates whether this reader is ready to be read without blocking. If
  the result is {@code true}, the next {@code read()} will not block. If
  the result is {@code false} then this reader may or may not block when
  {@code read()} is called. This implementation returns {@code true} if
  there are bytes available in the buffer or the source stream has bytes
  available.
  
  @return {@code true} if the receiver will not block when {@code read()}
  is called, {@code false} if unknown or blocking will occur.
  @throws IOException
  if this reader is closed or some other I/O error occurs.