RFR: 8356420: Provide examples on wrapping System.in [v2]

Naoto Sato naoto at openjdk.org
Fri May 9 21:29:09 UTC 2025


On Fri, 9 May 2025 21:10:02 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Reflects a review comment
>
> src/java.base/share/classes/java/lang/System.java line 135:
> 
>> 133:      * {@snippet lang=java :
>> 134:      *     new InputStreamReader(System.in, System.getProperty("stdin.encoding"));
>> 135:      * }
> 
> So, ok as far as it goes.  Does this example imply that one should always use the 2 arg constructor.
> When should the 1-arg constructor that uses the defaultEncoding vs the 2-arg constructor with stdin.encoding be used?
> Is that understood to be described elsewhere?

For reading from `System.in`, yes. For other cases, depends on the user's situation. This is the first to modify our documents to guide users as `stdin.encoding` is a new property. There are some descriptions for `System.out` and `System.err` in the JEP 400 though. Probably we will need to update the JEP too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25155#discussion_r2082519023


More information about the core-libs-dev mailing list