Closeable
, AutoCloseable
, InputStreamWrapper
public class InterruptableInputStream extends InputStream implements InputStreamWrapper
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.
Constructor | Description |
---|---|
InterruptableInputStream(InputStream inputStream) |
Modifier and Type | Method | Description |
---|---|---|
int |
available() |
|
void |
close() |
|
InputStream |
getWrappedInputStream() |
|
void |
interrupt() |
|
int |
read() |
|
int |
read(byte[] b,
int off,
int len) |
mark, markSupported, read, readAllBytes, readNBytes, reset, skip, transferTo
public InterruptableInputStream(InputStream inputStream)
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
close
in class InputStream
IOException
public InputStream getWrappedInputStream()
getWrappedInputStream
in interface InputStreamWrapper
public void interrupt()