Package org.jets3t.service.io
Class InterruptableInputStream
java.lang.Object
java.io.InputStream
org.jets3t.service.io.InterruptableInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,InputStreamWrapper
Input stream wrapper that allows the underlying wrapped input stream to be interrupted.
Every time a blocking stream operation is invoked on this class, the interrupt flag is
checked first. If this flag is set, the underlying stream is closed and an IOException
"Input Stream Interrupted" is thrown.
Note: This hacky class does not really solve the problem of interrupting blocking Java input streams, as it cannot unblock a blocked read operation. It really just serves as a convenient way to interrupt streams before any potentially blocking operations.
- Author:
- James Murty
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
InterruptableInputStream
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
getWrappedInputStream
- Specified by:
getWrappedInputStreamin interfaceInputStreamWrapper- Returns:
- the underlying input stream wrapped by this class.
-
interrupt
public void interrupt()
-