aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes BufferedReader.readLine doesn't return null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "BufferedReader.readLine doesn Watch "BufferedReader.readLine doesn New topic
Author

BufferedReader.readLine doesn't return null

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi there,

I'm trying to put together a simple Chat client/server application. The issue I'm having is with the Server app. I have a class that extends Thread which contains this call:
temp = input.readLine()
in the run() method. Everytime I connect with the client side app, an instance of this class "ReceivingThread" is created and is supposed to read in any messages coming in using a BufferedReader. That's the input variable type. According to the API readLine() is supposed to return null when there's nothing more to read in. In my code I check for null but it never seems to leave the while loop.

Please advise,

Alan

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

Originally posted by Alan Shiers:
According to the API readLine() is supposed to return null when there's nothing more to read in.


Close. It returns null when the stream reaches EOF. It blocks when there's nothing more to read. You probably need to close the stream on the other end.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Yep. That was it!
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BufferedReader.readLine doesn't return null