How to interrupt a method execution in java?
1 posts in topic
Flat View  Flat View

Posted By:   anu_pama
Posted On:   Tuesday, December 18, 2001 06:50 AM

How to come out of the ReadLine method execution before receiving end of line or carriage return with a line feed.

ReadLine of buffered Reader class has socket.getInputStream() has the argument.In this case the readLine method is expecting a stream from the socket, and before receiving a stream how can we come out of the method readLine.

Re: How to interrupt a method execution in java?

Posted By:   Alex_Chaffee  
Posted On:   Sunday, December 23, 2001 09:07 AM

You're confused. The API is very simple:

Socket s = new Socket(host, port);
InputStream in = s.getInputStream();
BufferedReader r = new BufferedReader(in);
String line = r.readLine();

At any rate, this is an IO question, having nothing to do with Threads. USe the IO FAQ instead.

You may also want to search for the FAQ on "non-blocking io" -- but I'm pretty sure that's not what you want.

About | Sitemap | Contact