code: public int available() throws IOException {
          ensureOpen();
          int n = buf.length - pos;
          int avail = super.available();
          return n > (Integer.MAX_VALUE - avail)
                      ? Integer.MAX_VALUE
                      : n + avail;
      }
docs: Returns an estimate of the number of bytes that can be read (or
  skipped over) from this input stream without blocking by the next
  invocation of a method for this input stream. The next invocation might be
  the same thread or another thread.  A single read or skip of this
  many bytes will not block, but may read or skip fewer bytes.
  
  <p> The method returns the sum of the number of bytes that have been
  pushed back and the value returned by {@link
  java.io.FilterInputStream#available available}.
  
  @return     the number of bytes that can be read (or skipped over) from
  the input stream without blocking.
  @exception  IOException  if this input stream has been closed by
  invoking its {@link #close()} method,
  or an I/O error occurs.
  @see        java.io.FilterInputStream#in
  @see        java.io.InputStream#available()