-
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks