reading from console, InputStreamReader etc.



Hi,
I've got 2 question:
1) I'd like to read a double value from console, so I wrote:

try{
char c = new char[100];
InputStreamReader isr = new InputStreamReader(System.in);
isr.read(c);
String s = new String(c);
double d = Double.parseDouble(s);
}
catch (IOException ioe) { }

Have I to write such much code to do such simple think?
In C++ I nead only:
double d;
cin >> d;

2) I need to detect is someone pres some key, without echo on console
and without press enter after key. In C++ it's like this:

char c = getch();

Is in Java something like this?

thanks in advance

.



Relevant Pages

  • Re: wprintf() could not display unicode chars which is > 255 to console?
    ... > console window with formatting strings. ... Unicode and the Windows console is a tricky business. ... string msg, action; ... In Japanese you should have no spaces, and the translator can remove them. ...
    (microsoft.public.vc.mfc)
  • Re: Command Line Interface
    ... This is somewhat I am aiming for, to be honest my idea for this is Java ... Netbean's 'console window' which it uses for user input and output. ... [user enters string and conv to double] ... CString GetString() ...
    (microsoft.public.vc.mfc)
  • Re: reading from console, InputStreamReader etc.
    ... I'd like to read a double value from console, ... String s = new String; ... C++ is generally a more terse language than Java. ... to a GUI component to capture key presses. ...
    (comp.lang.java.programmer)
  • Re: How do you inherit DOS console in Win32 application?
    ... > console in a Win32 assembly console application? ... ByVal lpFile As String, ByVal lpParameters As String, _ ... If your app is calling the command prompt, ... Dim hWnd As Long, iDummy As Long, sCmd As String ...
    (alt.lang.asm)
  • Attn:Mark Space... My Ascii 2 Hex back 2 Ascii program.
    ... It takes console input of an ascii ... converts it to it's Hex value and then converts the Hex value ... back to the Ascii string value. ...
    (comp.lang.java.help)