wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes streams Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "streams " Watch "streams " New topic
Author

streams

nitiish chinnaraju
Greenhorn

Joined: Jan 16, 2014
Posts: 13


in the above example the loop is not ending i dont know why? please tell me
Scott Winterbourne
Ranch Hand

Joined: Jan 30, 2014
Posts: 114
    
    1

Hi Nitiish,

Please put your code samples inside of [ code ] tags. It will make it much easier for everybody to read your code sample.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You're reading characters from System.in, i.e. the console, and continue to read until you reach the end of the stream. But when would you expect to reach the end of the stream of data coming from the console?
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2250
    
  47
Hi Nitiish,

In future please do as Scott has suggested and use code tags when posting code. Also make sure your code is properly formatted, I've added code tags to your post for you but because your code isn't formatted sensibly it's still really hard to read.

See how much easier the following is to read:
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Paul Clapham wrote:You're reading characters from System.in, i.e. the console, and continue to read until you reach the end of the stream. But when would you expect to reach the end of the stream of data coming from the console?

In the good old DOS there was the End-of-file control character (Ctrl-Z). Perhaps this would work in Java too?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Perhaps it would; I knew about that too (it was Ctrl-D in some other shells which I used a long time ago), but it might not be the best solution to the OP's problem.
 
Don't get me started about those stupid light bulbs.
 
subject: streams