code: public synchronized boolean ready() throws IOException {
          if (!connected) {
              throw new IOException("Pipe not connected");
          } else if (closedByReader) {
              throw new IOException("Pipe closed");
          } else if (writeSide != null && !writeSide.isAlive()
                     && !closedByWriter && (in < 0)) {
              throw new IOException("Write end dead");
          }
          if (in < 0) {
              return false;
          } else {
              return true;
          }
      }
docs: Tell whether this stream is ready to be read.  A piped character
  stream is ready if the circular buffer is not empty.
  
  @exception  IOException  if the pipe is
  <a href=PipedInputStream.html#BROKEN> <code>broken</code></a>,
  {@link #connect(java.io.PipedWriter) unconnected}, or closed.