Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EOF break when taking system in?

Status
Not open for further replies.

jisoo23

Programmer
Jan 27, 2004
192
US
Hello all,

This probably has a simple answer. I'm taking standard in from the command prompt (all integers) until I get an EOF. These integers are taken in via stringtokenizer. Trouble is I'm not sure what to look for to break my while look (which continually looks for tokens). I thought it might be null of "" but neither works. When I type in several ints, then leave the last blank and hit enter, I receive a "NoSuchElementException" error. I also get a different error if I use ctrl-D to send an EOF character (NumberFormatException: For Input String "(a diamond symbol?").

Can anyone toss me a clue here?

Thanks,
Jisoo23
 
Since System.in is an InputStream, is.available () might help.

But why don't you use the clear idea of Integers, and wait for a special character like 'q' as 'quit', and test for that?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top