wait until keypressed. or read key from user

This is a really easy question but i need to know right now. I made a little console application and at one point it has to wait for the user to type a character. how to solve it ????
master0084Asked:
Who is Participating?
 
muraliramConnect With a Mentor Commented:
Dear master,


 I think its beter t use.


BufferedReader b=new BufferedReader(new InputStreamReader(System.in)));

b.read();

as I found problems when waiting for one more character.


Bye

Murali

 
0
 
Sasha_MapaCommented:
First, what do you mean by "consol application". Does that mean you output text to the System.out stream and read text from System.in and nothing else?
System.in.read() would block until the user types something and when he does, the call would return the key he typed, does that do what you wanted?
0
 
master0084Author Commented:
This question has a deletion request Pending
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Sasha_MapaCommented:
This question no longer is pending deletion
0
 
Sasha_MapaCommented:
huh? Why delete the question? I think I answered it and muraliram proposed additional info for improving...
0
 
diakovCommented:
I think, the default input stream will wait until carriage return anyway.

Cheers,
  Nik
0
 
heyhey_Commented:
>> I think, the default input stream will wait until carriage return anyway.

standard DOS console buffers keyboard input and allows editing - that's why it won't return any char unil CR (it's not 'default input stream' :)

of course in.read will work for telnet app.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.