Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Detecting a null value from socket getOutputStream

843790Feb 26 2007 — edited Feb 27 2007
In this following line of codes
br = new BufferedReader(new InputStreamReader(soc.getInputStream()));
String message = br.readLine();

which i am using it with an JApplet whenever the client clicks on the recieve button this code gets executed,which reads the message from the server.But if the sever has not sent any message and if the client clicks on the recieve button control reaches the br.readLine(),and the program waits until it gets a message from the server,and if i want to click on any other button or stop the reading process nothing happens,it waits like in an endless loop.

I tried the following codes

if(br.ready())
{
message = br.readLine();
}
else
{
System.out.println("No message");
}

or


if(soc.getOutputStream().equals(""))
{
System.out.println("No message");
}
else
{
message = br.readLine();
}


but none of the code is working.

please help me
thank u
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2007
Added on Feb 26 2007
7 comments
637 views