Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8295672

Provide a better alternative to reading System.in

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • None
    • None
    • core-libs
    • None
    • generic
    • generic

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              naoto Naoto Sato
              naoto Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: