Possible Duplicate:
Is it possible to read from a Java InputStream with a timeout?
I noticed that when I was trying to read in more information then was sent to my server, the web browser would freeze. I saw that my socket froze, since the web browser was returning less information then it was trying to read. Is there a way to set out a time out on Currtly I’m using a input stream
public String ReadLine()
{
String out;
out="";
// read in one line
try{
request = new StringBuffer(1000);
boolean f=true;
while(true)
{
int c=in.read();
if (c=='\r')
{
// next should be a \n
// Program freezed hear
c=in.read();
if (f==true)
return "";
break;
}
f=false;
out=out+(char)c;
request.append((char)c);
} // end while
} catch(IOException ec)
{
System.out.println(ec.getMessage());
}
System.out.println(request);
return out;
}