src/java.base/share/classes/java/io/InputStream.java
changeset 58242 94bb65cb37d3
parent 58054 ee230ad8cfef
child 58288 48e480e56aad
equal deleted inserted replaced
58241:33de7752835c 58242:94bb65cb37d3
   175      *
   175      *
   176      * <p> A subclass must provide an implementation of this method.
   176      * <p> A subclass must provide an implementation of this method.
   177      *
   177      *
   178      * @return     the next byte of data, or <code>-1</code> if the end of the
   178      * @return     the next byte of data, or <code>-1</code> if the end of the
   179      *             stream is reached.
   179      *             stream is reached.
   180      * @exception  IOException  if an I/O error occurs.
   180      * @throws     IOException  if an I/O error occurs.
   181      */
   181      */
   182     public abstract int read() throws IOException;
   182     public abstract int read() throws IOException;
   183 
   183 
   184     /**
   184     /**
   185      * Reads some number of bytes from the input stream and stores them into
   185      * Reads some number of bytes from the input stream and stores them into
   206      *
   206      *
   207      * @param      b   the buffer into which the data is read.
   207      * @param      b   the buffer into which the data is read.
   208      * @return     the total number of bytes read into the buffer, or
   208      * @return     the total number of bytes read into the buffer, or
   209      *             <code>-1</code> if there is no more data because the end of
   209      *             <code>-1</code> if there is no more data because the end of
   210      *             the stream has been reached.
   210      *             the stream has been reached.
   211      * @exception  IOException  If the first byte cannot be read for any reason
   211      * @throws     IOException  If the first byte cannot be read for any reason
   212      * other than the end of the file, if the input stream has been closed, or
   212      *             other than the end of the file, if the input stream has been
   213      * if some other I/O error occurs.
   213      *             closed, or if some other I/O error occurs.
   214      * @exception  NullPointerException  if <code>b</code> is <code>null</code>.
   214      * @throws     NullPointerException  if <code>b</code> is <code>null</code>.
   215      * @see        java.io.InputStream#read(byte[], int, int)
   215      * @see        java.io.InputStream#read(byte[], int, int)
   216      */
   216      */
   217     public int read(byte b[]) throws IOException {
   217     public int read(byte b[]) throws IOException {
   218         return read(b, 0, b.length);
   218         return read(b, 0, b.length);
   219     }
   219     }
   264      *                   at which the data is written.
   264      *                   at which the data is written.
   265      * @param      len   the maximum number of bytes to read.
   265      * @param      len   the maximum number of bytes to read.
   266      * @return     the total number of bytes read into the buffer, or
   266      * @return     the total number of bytes read into the buffer, or
   267      *             <code>-1</code> if there is no more data because the end of
   267      *             <code>-1</code> if there is no more data because the end of
   268      *             the stream has been reached.
   268      *             the stream has been reached.
   269      * @exception  IOException If the first byte cannot be read for any reason
   269      * @throws     IOException If the first byte cannot be read for any reason
   270      * other than end of file, or if the input stream has been closed, or if
   270      *             other than end of file, or if the input stream has been closed,
   271      * some other I/O error occurs.
   271      *             or if some other I/O error occurs.
   272      * @exception  NullPointerException If <code>b</code> is <code>null</code>.
   272      * @throws     NullPointerException If <code>b</code> is <code>null</code>.
   273      * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
   273      * @throws     IndexOutOfBoundsException If <code>off</code> is negative,
   274      * <code>len</code> is negative, or <code>len</code> is greater than
   274      *             <code>len</code> is negative, or <code>len</code> is greater than
   275      * <code>b.length - off</code>
   275      *             <code>b.length - off</code>
   276      * @see        java.io.InputStream#read()
   276      * @see        java.io.InputStream#read()
   277      */
   277      */
   278     public int read(byte b[], int off, int len) throws IOException {
   278     public int read(byte b[], int off, int len) throws IOException {
   279         Objects.checkFromIndexSize(off, len, b.length);
   279         Objects.checkFromIndexSize(off, len, b.length);
   280         if (len == 0) {
   280         if (len == 0) {
   632      * <p> This method should be overridden by subclasses.
   632      * <p> This method should be overridden by subclasses.
   633      *
   633      *
   634      * @return     an estimate of the number of bytes that can be read (or
   634      * @return     an estimate of the number of bytes that can be read (or
   635      *             skipped over) from this input stream without blocking or
   635      *             skipped over) from this input stream without blocking or
   636      *             {@code 0} when it reaches the end of the input stream.
   636      *             {@code 0} when it reaches the end of the input stream.
   637      * @exception  IOException if an I/O error occurs.
   637      * @throws     IOException if an I/O error occurs.
   638      */
   638      */
   639     public int available() throws IOException {
   639     public int available() throws IOException {
   640         return 0;
   640         return 0;
   641     }
   641     }
   642 
   642 
   645      * with the stream.
   645      * with the stream.
   646      *
   646      *
   647      * <p> The <code>close</code> method of <code>InputStream</code> does
   647      * <p> The <code>close</code> method of <code>InputStream</code> does
   648      * nothing.
   648      * nothing.
   649      *
   649      *
   650      * @exception  IOException  if an I/O error occurs.
   650      * @throws     IOException  if an I/O error occurs.
   651      */
   651      */
   652     public void close() throws IOException {}
   652     public void close() throws IOException {}
   653 
   653 
   654     /**
   654     /**
   655      * Marks the current position in this input stream. A subsequent call to
   655      * Marks the current position in this input stream. A subsequent call to
   716      *     particular type of the input stream. </ul></ul>
   716      *     particular type of the input stream. </ul></ul>
   717      *
   717      *
   718      * <p>The method <code>reset</code> for class <code>InputStream</code>
   718      * <p>The method <code>reset</code> for class <code>InputStream</code>
   719      * does nothing except throw an <code>IOException</code>.
   719      * does nothing except throw an <code>IOException</code>.
   720      *
   720      *
   721      * @exception  IOException  if this stream has not been marked or if the
   721      * @throws  IOException  if this stream has not been marked or if the
   722      *               mark has been invalidated.
   722      *          mark has been invalidated.
   723      * @see     java.io.InputStream#mark(int)
   723      * @see     java.io.InputStream#mark(int)
   724      * @see     java.io.IOException
   724      * @see     java.io.IOException
   725      */
   725      */
   726     public synchronized void reset() throws IOException {
   726     public synchronized void reset() throws IOException {
   727         throw new IOException("mark/reset not supported");
   727         throw new IOException("mark/reset not supported");