How can I stop my console application using keyboard input (for example "q")
without blocking process.
Printable View
How can I stop my console application using keyboard input (for example "q")
without blocking process.
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.