equal
deleted
inserted
replaced
190 * buffer array of length <code>size</code> |
190 * buffer array of length <code>size</code> |
191 * is created and stored in <code>buf</code>. |
191 * is created and stored in <code>buf</code>. |
192 * |
192 * |
193 * @param in the underlying input stream. |
193 * @param in the underlying input stream. |
194 * @param size the buffer size. |
194 * @param size the buffer size. |
195 * @exception IllegalArgumentException if {@code size <= 0}. |
195 * @throws IllegalArgumentException if {@code size <= 0}. |
196 */ |
196 */ |
197 public BufferedInputStream(InputStream in, int size) { |
197 public BufferedInputStream(InputStream in, int size) { |
198 super(in); |
198 super(in); |
199 if (size <= 0) { |
199 if (size <= 0) { |
200 throw new IllegalArgumentException("Buffer size <= 0"); |
200 throw new IllegalArgumentException("Buffer size <= 0"); |
252 * the general contract of the <code>read</code> |
252 * the general contract of the <code>read</code> |
253 * method of <code>InputStream</code>. |
253 * method of <code>InputStream</code>. |
254 * |
254 * |
255 * @return the next byte of data, or <code>-1</code> if the end of the |
255 * @return the next byte of data, or <code>-1</code> if the end of the |
256 * stream is reached. |
256 * stream is reached. |
257 * @exception IOException if this input stream has been closed by |
257 * @throws IOException if this input stream has been closed by |
258 * invoking its {@link #close()} method, |
258 * invoking its {@link #close()} method, |
259 * or an I/O error occurs. |
259 * or an I/O error occurs. |
260 * @see java.io.FilterInputStream#in |
260 * @see java.io.FilterInputStream#in |
261 */ |
261 */ |
262 public synchronized int read() throws IOException { |
262 public synchronized int read() throws IOException { |
323 * @param b destination buffer. |
323 * @param b destination buffer. |
324 * @param off offset at which to start storing bytes. |
324 * @param off offset at which to start storing bytes. |
325 * @param len maximum number of bytes to read. |
325 * @param len maximum number of bytes to read. |
326 * @return the number of bytes read, or <code>-1</code> if the end of |
326 * @return the number of bytes read, or <code>-1</code> if the end of |
327 * the stream has been reached. |
327 * the stream has been reached. |
328 * @exception IOException if this input stream has been closed by |
328 * @throws IOException if this input stream has been closed by |
329 * invoking its {@link #close()} method, |
329 * invoking its {@link #close()} method, |
330 * or an I/O error occurs. |
330 * or an I/O error occurs. |
331 */ |
331 */ |
332 public synchronized int read(byte b[], int off, int len) |
332 public synchronized int read(byte b[], int off, int len) |
333 throws IOException |
333 throws IOException |
398 * the buffer (<code>count - pos</code>) and the result of calling the |
398 * the buffer (<code>count - pos</code>) and the result of calling the |
399 * {@link java.io.FilterInputStream#in in}.available(). |
399 * {@link java.io.FilterInputStream#in in}.available(). |
400 * |
400 * |
401 * @return an estimate of the number of bytes that can be read (or skipped |
401 * @return an estimate of the number of bytes that can be read (or skipped |
402 * over) from this input stream without blocking. |
402 * over) from this input stream without blocking. |
403 * @exception IOException if this input stream has been closed by |
403 * @throws IOException if this input stream has been closed by |
404 * invoking its {@link #close()} method, |
404 * invoking its {@link #close()} method, |
405 * or an I/O error occurs. |
405 * or an I/O error occurs. |
406 */ |
406 */ |
407 public synchronized int available() throws IOException { |
407 public synchronized int available() throws IOException { |
408 int n = count - pos; |
408 int n = count - pos; |
433 * (no mark has been set or the mark has been |
433 * (no mark has been set or the mark has been |
434 * invalidated), an <code>IOException</code> |
434 * invalidated), an <code>IOException</code> |
435 * is thrown. Otherwise, <code>pos</code> is |
435 * is thrown. Otherwise, <code>pos</code> is |
436 * set equal to <code>markpos</code>. |
436 * set equal to <code>markpos</code>. |
437 * |
437 * |
438 * @exception IOException if this stream has not been marked or, |
438 * @throws IOException if this stream has not been marked or, |
439 * if the mark has been invalidated, or the stream |
439 * if the mark has been invalidated, or the stream |
440 * has been closed by invoking its {@link #close()} |
440 * has been closed by invoking its {@link #close()} |
441 * method, or an I/O error occurs. |
441 * method, or an I/O error occurs. |
442 * @see java.io.BufferedInputStream#mark(int) |
442 * @see java.io.BufferedInputStream#mark(int) |
443 */ |
443 */ |
468 * associated with the stream. |
468 * associated with the stream. |
469 * Once the stream has been closed, further read(), available(), reset(), |
469 * Once the stream has been closed, further read(), available(), reset(), |
470 * or skip() invocations will throw an IOException. |
470 * or skip() invocations will throw an IOException. |
471 * Closing a previously closed stream has no effect. |
471 * Closing a previously closed stream has no effect. |
472 * |
472 * |
473 * @exception IOException if an I/O error occurs. |
473 * @throws IOException if an I/O error occurs. |
474 */ |
474 */ |
475 public void close() throws IOException { |
475 public void close() throws IOException { |
476 byte[] buffer; |
476 byte[] buffer; |
477 while ( (buffer = buf) != null) { |
477 while ( (buffer = buf) != null) { |
478 if (U.compareAndSetReference(this, BUF_OFFSET, buffer, null)) { |
478 if (U.compareAndSetReference(this, BUF_OFFSET, buffer, null)) { |