Solved

wait until keypressed. or read key from user

Posted on 2000-03-31
7
913 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
Comment Utility
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 50 total points
Comment Utility
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
Comment Utility
This question has a deletion request Pending
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

by:Sasha_Mapa
Comment Utility
This question no longer is pending deletion
0
 
LVL 7

Expert Comment

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

Expert Comment

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

Cheers,
  Nik
0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
>> 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now