org.jasen.io
Class NonBlockingStreamReader
java.lang.Object
org.jasen.io.NonBlockingStreamReader
- public class NonBlockingStreamReader
- extends Object
Implements a threaded input stream reader which can be terminated if it blocks for too long.
- Author:
- Jason Polites
Method Summary |
void |
read(InputStream in,
OutputStream out,
int bufferSize,
long timeout,
byte[] terminator)
Reads from the specified stream with the give buffer size and writes to the specified output stream. |
NonBlockingStreamReader
public NonBlockingStreamReader()
NonBlockingStreamReader
public NonBlockingStreamReader(StreamReaderListener streamReaderListener)
read
public void read(InputStream in,
OutputStream out,
int bufferSize,
long timeout,
byte[] terminator)
throws IOException
- Reads from the specified stream with the give buffer size and writes to the specified output stream.
If the reader blocks on a read() call for more than timeout milliseconds, the read process is abnormally aborted and an IOException is thrown
- Parameters:
in
- The inputstream from which to readout
- The outputstream to which to writebufferSize
- The size of the buffer (in bytes) to use when reading/writingtimeout
- The timeout (in milliseconds) to allow the read to block until bytes are available from the stream
- Throws:
IOException
- If an error occurred while reading the stream, or the read timed out