-
Keyboard input
How can I stop my console application using keyboard input (for example "q")
without blocking process.
-
Re: Keyboard input
If I understand your question correctly (and I probably don't)....you want
to quit the application from the command prompt once the letter q is
entered. All you need to do is read the input, and if the input matches
then call System.exit().
ie.
import java.io.*;
public class sysIn {
public static void main(String args[]) {
try {
BufferedReader in = new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Name:");
String s1 = in.readLine();
if(s1.equals("q"))
System.exit(0);
System.out.println("this is the end");
}
catch (IOException io) {}
}
}
"Azzi" <nikitab@moscow.vestedev.com> wrote in message
news:3a8fba52$1@news.devx.com...
>
> How can I stop my console application using keyboard input (for example
"q")
> without blocking process.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|