src/java.base/share/classes/java/io/Reader.java

Print this page
rev 11891 : 8029689: (spec) Reader.read(char[], int, int) throws unspecified IndexOutOfBoundsException
Reviewed-by: Stephen Hawking, Hedonismbot


 136      *
 137      * @exception   IOException  If an I/O error occurs
 138      */
 139     public int read(char cbuf[]) throws IOException {
 140         return read(cbuf, 0, cbuf.length);
 141     }
 142 
 143     /**
 144      * Reads characters into a portion of an array.  This method will block
 145      * until some input is available, an I/O error occurs, or the end of the
 146      * stream is reached.
 147      *
 148      * @param      cbuf  Destination buffer
 149      * @param      off   Offset at which to start storing characters
 150      * @param      len   Maximum number of characters to read
 151      *
 152      * @return     The number of characters read, or -1 if the end of the
 153      *             stream has been reached
 154      *
 155      * @exception  IOException  If an I/O error occurs



 156      */
 157     abstract public int read(char cbuf[], int off, int len) throws IOException;
 158 
 159     /** Maximum skip-buffer size */
 160     private static final int maxSkipBufferSize = 8192;
 161 
 162     /** Skip buffer, null until allocated */
 163     private char skipBuffer[] = null;
 164 
 165     /**
 166      * Skips characters.  This method will block until some characters are
 167      * available, an I/O error occurs, or the end of the stream is reached.
 168      *
 169      * @param  n  The number of characters to skip
 170      *
 171      * @return    The number of characters actually skipped
 172      *
 173      * @exception  IllegalArgumentException  If <code>n</code> is negative.
 174      * @exception  IOException  If an I/O error occurs
 175      */




 136      *
 137      * @exception   IOException  If an I/O error occurs
 138      */
 139     public int read(char cbuf[]) throws IOException {
 140         return read(cbuf, 0, cbuf.length);
 141     }
 142 
 143     /**
 144      * Reads characters into a portion of an array.  This method will block
 145      * until some input is available, an I/O error occurs, or the end of the
 146      * stream is reached.
 147      *
 148      * @param      cbuf  Destination buffer
 149      * @param      off   Offset at which to start storing characters
 150      * @param      len   Maximum number of characters to read
 151      *
 152      * @return     The number of characters read, or -1 if the end of the
 153      *             stream has been reached
 154      *
 155      * @exception  IOException  If an I/O error occurs
 156      * @exception  IndexOutOfBoundsException
 157      *             If {@code off} is negative, or {@code len} is negative,
 158      *             or {@code len} is greater than {@code cbuf.length - off}
 159      */
 160     abstract public int read(char cbuf[], int off, int len) throws IOException;
 161 
 162     /** Maximum skip-buffer size */
 163     private static final int maxSkipBufferSize = 8192;
 164 
 165     /** Skip buffer, null until allocated */
 166     private char skipBuffer[] = null;
 167 
 168     /**
 169      * Skips characters.  This method will block until some characters are
 170      * available, an I/O error occurs, or the end of the stream is reached.
 171      *
 172      * @param  n  The number of characters to skip
 173      *
 174      * @return    The number of characters actually skipped
 175      *
 176      * @exception  IllegalArgumentException  If <code>n</code> is negative.
 177      * @exception  IOException  If an I/O error occurs
 178      */