RFR: 8354724: BufferedReader readAllLines and readString methods [v5]

Shaojin Wen swen at openjdk.org
Fri Apr 18 02:55:42 UTC 2025


On Thu, 17 Apr 2025 23:07:35 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 two additional commits since the last revision:
> 
>  - 8354724: Increment copyright year in Reader
>  - 8354724: Move readString from BufferedReader to Reader

src/java.base/share/classes/java/io/Reader.java line 420:

> 418:      */
> 419:     public String readString() throws IOException {
> 420:         StringBuilder result = new StringBuilder();

StringBuilder result = new StringBuilder().append('\u4e2d').delete(0, 1);

Of course, we can also create a StringBuilder with coder as UTF16 in this way, but such code smells bad.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2049934073


More information about the core-libs-dev mailing list