src/java.base/share/classes/java/io/BufferedReader.java
changeset 58242 94bb65cb37d3
parent 58089 e64fec9f1773
child 58288 48e480e56aad
equal deleted inserted replaced
58241:33de7752835c 58242:94bb65cb37d3
    93      * the specified size.
    93      * the specified size.
    94      *
    94      *
    95      * @param  in   A Reader
    95      * @param  in   A Reader
    96      * @param  sz   Input-buffer size
    96      * @param  sz   Input-buffer size
    97      *
    97      *
    98      * @exception  IllegalArgumentException  If {@code sz <= 0}
    98      * @throws IllegalArgumentException  If {@code sz <= 0}
    99      */
    99      */
   100     public BufferedReader(Reader in, int sz) {
   100     public BufferedReader(Reader in, int sz) {
   101         super(in);
   101         super(in);
   102         if (sz <= 0)
   102         if (sz <= 0)
   103             throw new IllegalArgumentException("Buffer size <= 0");
   103             throw new IllegalArgumentException("Buffer size <= 0");
   170      * Reads a single character.
   170      * Reads a single character.
   171      *
   171      *
   172      * @return The character read, as an integer in the range
   172      * @return The character read, as an integer in the range
   173      *         0 to 65535 ({@code 0x00-0xffff}), or -1 if the
   173      *         0 to 65535 ({@code 0x00-0xffff}), or -1 if the
   174      *         end of the stream has been reached
   174      *         end of the stream has been reached
   175      * @exception  IOException  If an I/O error occurs
   175      * @throws     IOException  If an I/O error occurs
   176      */
   176      */
   177     public int read() throws IOException {
   177     public int read() throws IOException {
   178         synchronized (lock) {
   178         synchronized (lock) {
   179             ensureOpen();
   179             ensureOpen();
   180             for (;;) {
   180             for (;;) {
   269      * @param      len   Maximum number of characters to read
   269      * @param      len   Maximum number of characters to read
   270      *
   270      *
   271      * @return     The number of characters read, or -1 if the end of the
   271      * @return     The number of characters read, or -1 if the end of the
   272      *             stream has been reached
   272      *             stream has been reached
   273      *
   273      *
   274      * @exception  IOException  If an I/O error occurs
   274      * @throws     IOException  If an I/O error occurs
   275      * @exception  IndexOutOfBoundsException {@inheritDoc}
   275      * @throws     IndexOutOfBoundsException {@inheritDoc}
   276      */
   276      */
   277     public int read(char cbuf[], int off, int len) throws IOException {
   277     public int read(char cbuf[], int off, int len) throws IOException {
   278         synchronized (lock) {
   278         synchronized (lock) {
   279             ensureOpen();
   279             ensureOpen();
   280             if ((off < 0) || (off > cbuf.length) || (len < 0) ||
   280             if ((off < 0) || (off > cbuf.length) || (len < 0) ||
   309      *             any line-termination characters, or null if the end of the
   309      *             any line-termination characters, or null if the end of the
   310      *             stream has been reached without reading any characters
   310      *             stream has been reached without reading any characters
   311      *
   311      *
   312      * @see        java.io.LineNumberReader#readLine()
   312      * @see        java.io.LineNumberReader#readLine()
   313      *
   313      *
   314      * @exception  IOException  If an I/O error occurs
   314      * @throws     IOException  If an I/O error occurs
   315      */
   315      */
   316     String readLine(boolean ignoreLF, boolean[] term) throws IOException {
   316     String readLine(boolean ignoreLF, boolean[] term) throws IOException {
   317         StringBuffer s = null;
   317         StringBuffer s = null;
   318         int startChar;
   318         int startChar;
   319 
   319 
   386      *
   386      *
   387      * @return     A String containing the contents of the line, not including
   387      * @return     A String containing the contents of the line, not including
   388      *             any line-termination characters, or null if the end of the
   388      *             any line-termination characters, or null if the end of the
   389      *             stream has been reached without reading any characters
   389      *             stream has been reached without reading any characters
   390      *
   390      *
   391      * @exception  IOException  If an I/O error occurs
   391      * @throws     IOException  If an I/O error occurs
   392      *
   392      *
   393      * @see java.nio.file.Files#readAllLines
   393      * @see java.nio.file.Files#readAllLines
   394      */
   394      */
   395     public String readLine() throws IOException {
   395     public String readLine() throws IOException {
   396         return readLine(false, null);
   396         return readLine(false, null);
   401      *
   401      *
   402      * @param  n  The number of characters to skip
   402      * @param  n  The number of characters to skip
   403      *
   403      *
   404      * @return    The number of characters actually skipped
   404      * @return    The number of characters actually skipped
   405      *
   405      *
   406      * @exception  IllegalArgumentException  If <code>n</code> is negative.
   406      * @throws     IllegalArgumentException  If <code>n</code> is negative.
   407      * @exception  IOException  If an I/O error occurs
   407      * @throws     IOException  If an I/O error occurs
   408      */
   408      */
   409     public long skip(long n) throws IOException {
   409     public long skip(long n) throws IOException {
   410         if (n < 0L) {
   410         if (n < 0L) {
   411             throw new IllegalArgumentException("skip value is negative");
   411             throw new IllegalArgumentException("skip value is negative");
   412         }
   412         }
   442     /**
   442     /**
   443      * Tells whether this stream is ready to be read.  A buffered character
   443      * Tells whether this stream is ready to be read.  A buffered character
   444      * stream is ready if the buffer is not empty, or if the underlying
   444      * stream is ready if the buffer is not empty, or if the underlying
   445      * character stream is ready.
   445      * character stream is ready.
   446      *
   446      *
   447      * @exception  IOException  If an I/O error occurs
   447      * @throws     IOException  If an I/O error occurs
   448      */
   448      */
   449     public boolean ready() throws IOException {
   449     public boolean ready() throws IOException {
   450         synchronized (lock) {
   450         synchronized (lock) {
   451             ensureOpen();
   451             ensureOpen();
   452 
   452 
   489      *                         A limit value larger than the size of the input
   489      *                         A limit value larger than the size of the input
   490      *                         buffer will cause a new buffer to be allocated
   490      *                         buffer will cause a new buffer to be allocated
   491      *                         whose size is no smaller than limit.
   491      *                         whose size is no smaller than limit.
   492      *                         Therefore large values should be used with care.
   492      *                         Therefore large values should be used with care.
   493      *
   493      *
   494      * @exception  IllegalArgumentException  If {@code readAheadLimit < 0}
   494      * @throws     IllegalArgumentException  If {@code readAheadLimit < 0}
   495      * @exception  IOException  If an I/O error occurs
   495      * @throws     IOException  If an I/O error occurs
   496      */
   496      */
   497     public void mark(int readAheadLimit) throws IOException {
   497     public void mark(int readAheadLimit) throws IOException {
   498         if (readAheadLimit < 0) {
   498         if (readAheadLimit < 0) {
   499             throw new IllegalArgumentException("Read-ahead limit < 0");
   499             throw new IllegalArgumentException("Read-ahead limit < 0");
   500         }
   500         }
   507     }
   507     }
   508 
   508 
   509     /**
   509     /**
   510      * Resets the stream to the most recent mark.
   510      * Resets the stream to the most recent mark.
   511      *
   511      *
   512      * @exception  IOException  If the stream has never been marked,
   512      * @throws     IOException  If the stream has never been marked,
   513      *                          or if the mark has been invalidated
   513      *                          or if the mark has been invalidated
   514      */
   514      */
   515     public void reset() throws IOException {
   515     public void reset() throws IOException {
   516         synchronized (lock) {
   516         synchronized (lock) {
   517             ensureOpen();
   517             ensureOpen();