RFR: 8354724: BufferedReader readAllLines and readString methods [v2]
Roger Riggs
rriggs at openjdk.org
Thu Apr 17 19:30:48 UTC 2025
On Thu, 17 Apr 2025 18:45:13 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: Address all PR comments to now
The base `Reader` class has no concept of lines, only a stream of `char`.
The BufferedReader methods for `readline()`, `Stream<String>`, and these new line oriented methods are complementary.
src/java.base/share/classes/java/io/BufferedReader.java line 417:
> 415: * the expression:
> 416: * <blockquote>{@link #lines()}.toList()</blockquote>
> 417: *
It is worth noting that if an IOException occurs, the reader and underlying stream are left in an unpredictable state?
With a normal or exceptional return should anything be said about the state of the underlying stream?
The corresponding method on Files ensures the reader is closed (and propagates to the underlying stream).
src/java.base/share/classes/java/io/BufferedReader.java line 426:
> 424: * {@code List} is modifiable is implementation dependent,
> 425: * hence not specified
> 426: *
Does the rationale used in Files to leaving this indeterminate apply here?
I'd think it would be better to say its not-modifyable.
Here its free/cheap, the Stream<T>.toList() method creates an un-modifiableList.
-------------
PR Review: https://git.openjdk.org/jdk/pull/24728#pullrequestreview-2776680615
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2049505815
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2049507765
More information about the core-libs-dev
mailing list