what is the value of Escape key?

Hi

i have a n00b question but have already spent quite some time on it, without a positive result, hence the post!

Basically i want to get input from user, append it to a file and quit when user presses the escape key.

===========================================================

System.out.println("Enter the text to be written:");

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

{

//Problem line ..i dont know what to put in here

while(c=(in.read()) != "")

{

filewriter.write(c);

}

[584 byte] By [karanJa] at [2007-11-27 6:38:31]
# 1
There's no character associated with the escape key. If you were capturing key events in swing, it would be possible, but since pressing escape doesn't put any character into the standard input stream, there's nothing for your BufferedReader to read.
hunter9000a at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 2
Really the 'Escape Key" is Char 27, but that's the the key at the top of your keyboard though...
Vagabona at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 3
Just ask them to enter q or quit to end the while loop.
_helloWorld_a at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 4
thanks Helloworld lets say if i use "QUIT" as the escape word, then how do i use it in the while loop as read() returns int value. I cant compare a string"quit" with integer value.
karanJa at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 5

> thanks Helloworld

>

> lets say if i use "QUIT" as the escape word, then how

> do i use it in the while loop as read() returns int

> value. I cant compare a string"quit" with integer

> value.

Read the input as a line, not a single character. Then you can compare the input to the "quit" string.

hunter9000a at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 6
If this is all the input you will be reading from System.in, you can instruct the userto terminate input by closing the stream (Ctrl+Z in Windows, Ctrl+D in Unix)
Hippolytea at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 7
The windows key is called the 'super key' in reality, if you need to google for help.
Vagabona at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...
# 8
> The windows key is called the 'super key' in reality,> if you need to google for help.Nobody asked about the windows key. Anyway I thought the value of the escape key was $7.50.
floundera at 2007-7-12 18:07:12 > top of Java-index,Java Essentials,New To Java...