RFR: 8354724: BufferedReader readAllLines and readString methods [v12]
Johannes Döbler
duke at openjdk.org
Wed Apr 23 16:12:46 UTC 2025
On Tue, 22 Apr 2025 17:12:52 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: Add missing toList(), tweak verbiage; update test
test/jdk/java/io/BufferedReader/ReadAll.java line 72:
> 70: int size = rnd.nextInt(2, 16386);
> 71:
> 72: try (FileChannel fc = FileChannel.open(path, CREATE, WRITE)) {
Why not just create a `List<String>` of lines and then write it to the file using `Files.write(Path, Iterable<? extends CharSequence>, Charset, OpenOption...)`
test/jdk/java/io/BufferedReader/ReadAll.java line 107:
> 105: List<String> lines;
> 106: try (FileReader fr = new FileReader(file);
> 107: BufferedReader br = new BufferedReader(fr)) {
could be simplified to
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2056402107
PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2056407359
More information about the core-libs-dev
mailing list