Solved

wait until keypressed. or read key from user

Posted on 2000-03-31
7
917 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 50 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
type mismatch (Object[] to double[] 4 33
ejb stateless example 2 25
Notify sent to other threads in Java 9 33
Eclipse for Java EE development 2 28
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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.

860 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