8248383: Clarify java.io.Reader.read(char[], ...) behavior for full array

Reviewed-by: naoto, smarks, rriggs
This commit is contained in:
Brian Burkhalter 2020-12-17 16:29:57 +00:00
parent 8251b74665
commit 143998e46c
2 changed files with 95 additions and 0 deletions

View file

@ -217,6 +217,12 @@ public abstract class Reader implements Readable, Closeable {
* Reads characters into an array. This method will block until some input
* is available, an I/O error occurs, or the end of the stream is reached.
*
* <p> If the length of {@code cbuf} is zero, then no characters are read
* and {@code 0} is returned; otherwise, there is an attempt to read at
* least one character. If no character is available because the stream is
* at its end, the value {@code -1} is returned; otherwise, at least one
* character is read and stored into {@code cbuf}.
*
* @param cbuf Destination buffer
*
* @return The number of characters read, or -1
@ -234,6 +240,12 @@ public abstract class Reader implements Readable, Closeable {
* until some input is available, an I/O error occurs, or the end of the
* stream is reached.
*
* <p> If {@code len} is zero, then no characters are read and {@code 0} is
* returned; otherwise, there is an attempt to read at least one character.
* If no character is available because the stream is at its end, the value
* {@code -1} is returned; otherwise, at least one character is read and
* stored into {@code cbuf}.
*
* @param cbuf Destination buffer
* @param off Offset at which to start storing characters
* @param len Maximum number of characters to read