reading from console, InputStreamReader etc.
- From: mehafi@xxxxxxxxx
- Date: Thu, 02 Aug 2007 03:59:01 -0700
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
.
- Follow-Ups:
- Re: reading from console, InputStreamReader etc.
- From: Arne Vajhøj
- Re: reading from console, InputStreamReader etc.
- From: Patricia Shanahan
- Re: reading from console, InputStreamReader etc.
- Prev by Date: tomcat problems
- Next by Date: Placing properties files on EAR, instead of WAR file
- Previous by thread: tomcat problems
- Next by thread: Re: reading from console, InputStreamReader etc.
- Index(es):
Relevant Pages
|