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

System.in always works in "cooked" mode

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000



      Name: nt126004 Date: 07/19/2002


      FULL PRODUCT VERSION :
      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Windows 2000

      ADDITIONAL OPERATING SYSTEMS :
      Linux


      A DESCRIPTION OF THE PROBLEM :
      As of JDK 1.4 there seems to be no way to get the input
      buffer (via System.in) unless a newline is also
      entered. InputStream/Reader methods like available()
      and ready() return 0/false until a newline
      is entered).

      This means <tt>System.in</tt> always appears to
      work in "cooked" mode (both on windows and an linux).

      This makes writing command line type programs and
      also games very hard in Java.

      System.in should be enhanced to allow "raw" input.

      Actually, the same problem exists in previous versions
      of the JDK too. It really is a OS-dependent thing
      (there is a syscall in Unix to turn on/off cooked mode
      for terminal/console input).

      So, it would be nice for a method call or parameter
      via which the Java user could specify cooked vs. raw
      for System.in.
      [say, java.lang.System.setSystemInCooked(false/true)]

      That way, the JVM could do whatever needs to be
      done for the platform it was running on. Without
      the ability to specify cooked vs raw in java, it
      becomes impossible to write portable programs that
      expect immediate input from the user via the terminal.

      This is mentioned in the java FAQ too (I think) and
      it's been discussed on comp.lang.lava.programmerbefore.
      There really isn't a portable solution until andunless
      this functionality in incorporated in Java. (would
      be nice in JDK 1.5)

      REPRODUCIBILITY :
      This bug can be reproduced always.
      (Review ID: 158682)
      ======================================================================

            mr Mark Reinhold
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: