United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4717813 : System.in always works in "cooked" mode

Details
Type:
Enhancement
Submit Date:
2002-07-19
Status:
Closed
Updated Date:
2003-01-31
Project Name:
JDK
Resolved Date:
2003-01-31
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.io
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.4.0
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description

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) 
======================================================================

                                    

Comments



Hardware and Software, Engineered to Work Together