Solved

wait until keypressed. or read key from user

Posted on 2000-03-31
7
919 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

710 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