Reading data from the console to exit

I have an program which keeps running all the time and when ever i type "EXIT" in the command prompt, the java application should stop running.. Can anybody help me out in this

I have the sample code likethis

class Sample{

publicstaticvoid main( String args[])

{

while(true)

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

String stop=br.readLine();

if(stop.equals("x"))

break;

// or else stop the application directly ..

else

{

//do some task..

}

}

}

This program shouldnot stop running unless i give exit.

The looping shouldnot wait untill i press enter every time.

If i run the program now, each and every time we have to give ENTER to continue our task .. Is there any other way to do it so.

[1530 byte] By [Uppalapatia] at [2007-10-3 3:46:03]
# 1
Create the buffered reader before the loop.
ejpa at 2007-7-14 21:42:40 > top of Java-index,Core,Core APIs...
# 2
I have tried that also but it didnt solve my problem.
Uppalapatia at 2007-7-14 21:42:40 > top of Java-index,Core,Core APIs...
# 3
A buffered reader is supposed to be able to read a line. Suppose I started to type in the letters EXIT. At this this moment how can you know I am going to type further letters or the line is ready, apart from my having typed return?
BIJ001a at 2007-7-14 21:42:40 > top of Java-index,Core,Core APIs...
# 4
> Create the buffered reader before the loop.I have tried that way also but dint work out..
Uppalapatia at 2007-7-14 21:42:40 > top of Java-index,Core,Core APIs...
# 5

> A buffered reader is supposed to be able to read a

> line.

>

> Suppose I started to type in the letters EXIT. At

> this this moment how can you know I am going to type

> further letters or the line is ready, apart from my

> having typed return?

Instead of the word EXIT , let me have the letter X , so now when i give the letter X, then the loop should break.

Uppalapatia at 2007-7-14 21:42:40 > top of Java-index,Core,Core APIs...
# 6

Assume I have typed X but I am still pondering wether to delete it back and replace with something differerent.

Okay, you can have a terminal in line-editing mode enabling you to delete back etc. or have the reading applaication have any caharacter immediately as the user hit a key. Unfortunately Java does not support the latter. If feasible and applicable, GUI can be used instead.

Cf also:

http://sourceforge.net/projects/javacurses/

BIJ001a at 2007-7-14 21:42:40 > top of Java-index,Core,Core APIs...