Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

wait until keypressed. or read key from user

Posted on 2000-03-31
7
Medium Priority
?
924 Views
Last Modified: 2008-02-26
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 ????
0
Comment
Question by:master0084
7 Comments
 
LVL 7

Expert Comment

by:Sasha_Mapa
ID: 2672877
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
 
LVL 2

Accepted Solution

by:
muraliram earned 100 total points
ID: 2672932
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
 

Author Comment

by:master0084
ID: 2673019
This question has a deletion request Pending
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Sasha_Mapa
ID: 2673747
This question no longer is pending deletion
0
 
LVL 7

Expert Comment

by:Sasha_Mapa
ID: 2673748
huh? Why delete the question? I think I answered it and muraliram proposed additional info for improving...
0
 
LVL 8

Expert Comment

by:diakov
ID: 2674110
I think, the default input stream will wait until carriage return anyway.

Cheers,
  Nik
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2675619
>> 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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question