RFR: 8354724: Methods in java.io.Reader to read all characters and all lines [v19]
Stuart Marks
smarks at openjdk.org
Wed May 14 17:03:56 UTC 2025
On Tue, 13 May 2025 15:33:39 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Implement the requested methods and add a test thereof.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8354724: "stream" -> "reader"
src/java.base/share/classes/java/io/Reader.java line 403:
> 401: char[] str = new char[TRANSFER_BUFFER_SIZE];
> 402: int n;
> 403: while ((n = read(str)) != -1) {
I'd suggest changing this call to `this.read(str, 0, str.length)` so that all concrete implementations in this class call only the abstract three-arg read() method. Using `this` is optional but it emphasizes that this is a self-call. (It's done in only one other place in this file already.)
Also, the variable name `str` is confusing since this isn't a String. I'd suggest `cbuf` instead as that name is used for char arrays elsewhere.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089375168
More information about the core-libs-dev
mailing list