Reading `System.in` is problematic as it is an input stream encoded in the host's encoding. With the JEP 400, there are cases where the default encoding (UTF-8) and host's native encoding differ. To read the bytes correctly, users would have to convert the bytes native-to-default, which seems to be an obstacle for basic usage. Providing a better means to access (w/o considering encoding stuff) would be appropriate. One option is to let users to use System.console(), but it won't work if the JVM is not attached to a console.
Some possible options include:
- Scanner.consoleScanner(): Returns Console.reader()
- Reader.consoleReader(): Returns Console.reader()
- System.inReader(): Returns Console.reader() if exists, otherwise a BufferedReader on System.in
Some possible options include:
- Scanner.consoleScanner(): Returns Console.reader()
- Reader.consoleReader(): Returns Console.reader()
- System.inReader(): Returns Console.reader() if exists, otherwise a BufferedReader on System.in
- relates to
-
JDK-8187041 JEP 400: UTF-8 by Default
-
- Closed
-