Solved

wait until keypressed. or read key from user

Posted on 2000-03-31
7
920 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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.

632 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