- java.lang.Object
-
- java.io.InputStream
-
- org.refcodes.io.BlockingInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class BlockingInputStream extends InputStream
TheBlockingInputStream
wraps anInputStream
adding blocking functionality, e.g. when trying to read the read operation is blocked tillavailable()
returns a value greater than 0. Use aTimeoutInputStream
to combine theBlockingInputStream
with a timeout.
-
-
Constructor Summary
Constructors Constructor Description BlockingInputStream(InputStream aInputStream)
Decorates the providedInputStream
blocking functionality
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
void
mark(int readlimit)
boolean
markSupported()
int
read()
int
read(byte[] aB)
int
read(byte[] aB, int aOff, int aLen)
byte[]
readAllBytes()
int
readNBytes(byte[] aB, int aOff, int aLen)
void
reset()
-
Methods inherited from class java.io.InputStream
nullInputStream, readNBytes, skip, transferTo
-
-
-
-
Constructor Detail
-
BlockingInputStream
public BlockingInputStream(InputStream aInputStream)
Decorates the providedInputStream
blocking functionality- Parameters:
aInputStream
- TheInputStream
to be decorated accordingly.
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] aB) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] aB, int aOff, int aLen) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
readAllBytes
public byte[] readAllBytes() throws IOException
- Overrides:
readAllBytes
in classInputStream
- Throws:
IOException
-
readNBytes
public int readNBytes(byte[] aB, int aOff, int aLen) throws IOException
- Overrides:
readNBytes
in classInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classInputStream
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
-