378 }
379
380 /**
381 * Returns an estimate of the number of bytes that can be read (or
382 * skipped over) from this input stream without blocking by the next
383 * invocation of a method for this input stream. The next invocation might be
384 * the same thread or another thread. A single read or skip of this
385 * many bytes will not block, but may read or skip fewer bytes.
386 * <p>
387 * This method returns the sum of the number of bytes remaining to be read in
388 * the buffer (<code>count - pos</code>) and the result of calling the
389 * {@link java.io.FilterInputStream#in in}.available().
390 *
391 * @return an estimate of the number of bytes that can be read (or skipped
392 * over) from this input stream without blocking.
393 * @exception IOException if this input stream has been closed by
394 * invoking its {@link #close()} method,
395 * or an I/O error occurs.
396 */
397 public synchronized int available() throws IOException {
398 return getInIfOpen().available() + (count - pos);
399 }
400
401 /**
402 * See the general contract of the <code>mark</code>
403 * method of <code>InputStream</code>.
404 *
405 * @param readlimit the maximum limit of bytes that can be read before
406 * the mark position becomes invalid.
407 * @see java.io.BufferedInputStream#reset()
408 */
409 public synchronized void mark(int readlimit) {
410 marklimit = readlimit;
411 markpos = pos;
412 }
413
414 /**
415 * See the general contract of the <code>reset</code>
416 * method of <code>InputStream</code>.
417 * <p>
418 * If <code>markpos</code> is <code>-1</code>
|
378 }
379
380 /**
381 * Returns an estimate of the number of bytes that can be read (or
382 * skipped over) from this input stream without blocking by the next
383 * invocation of a method for this input stream. The next invocation might be
384 * the same thread or another thread. A single read or skip of this
385 * many bytes will not block, but may read or skip fewer bytes.
386 * <p>
387 * This method returns the sum of the number of bytes remaining to be read in
388 * the buffer (<code>count - pos</code>) and the result of calling the
389 * {@link java.io.FilterInputStream#in in}.available().
390 *
391 * @return an estimate of the number of bytes that can be read (or skipped
392 * over) from this input stream without blocking.
393 * @exception IOException if this input stream has been closed by
394 * invoking its {@link #close()} method,
395 * or an I/O error occurs.
396 */
397 public synchronized int available() throws IOException {
398 int n = count - pos;
399 int avail = getInIfOpen().available();
400 return n > (Integer.MAX_VALUE - avail)
401 ? Integer.MAX_VALUE
402 : n + avail;
403 }
404
405 /**
406 * See the general contract of the <code>mark</code>
407 * method of <code>InputStream</code>.
408 *
409 * @param readlimit the maximum limit of bytes that can be read before
410 * the mark position becomes invalid.
411 * @see java.io.BufferedInputStream#reset()
412 */
413 public synchronized void mark(int readlimit) {
414 marklimit = readlimit;
415 markpos = pos;
416 }
417
418 /**
419 * See the general contract of the <code>reset</code>
420 * method of <code>InputStream</code>.
421 * <p>
422 * If <code>markpos</code> is <code>-1</code>
|