jdk/src/share/classes/java/io/BufferedInputStream.java
changeset 7280 81f10887bf74
parent 5506 202f599c92aa
child 7668 d4a77089c587
equal deleted inserted replaced
7279:32ac37aa9367 7280:81f10887bf74
   393      * @exception  IOException  if this input stream has been closed by
   393      * @exception  IOException  if this input stream has been closed by
   394      *                          invoking its {@link #close()} method,
   394      *                          invoking its {@link #close()} method,
   395      *                          or an I/O error occurs.
   395      *                          or an I/O error occurs.
   396      */
   396      */
   397     public synchronized int available() throws IOException {
   397     public synchronized int available() throws IOException {
   398         return getInIfOpen().available() + (count - pos);
   398         int n = count - pos;
       
   399         int avail = getInIfOpen().available();
       
   400         return n > (Integer.MAX_VALUE - avail)
       
   401                     ? Integer.MAX_VALUE
       
   402                     : n + avail;
   399     }
   403     }
   400 
   404 
   401     /**
   405     /**
   402      * See the general contract of the <code>mark</code>
   406      * See the general contract of the <code>mark</code>
   403      * method of <code>InputStream</code>.
   407      * method of <code>InputStream</code>.