- java.lang.Object
-
- java.io.InputStream
-
- org.refcodes.io.ReplayInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class ReplayInputStream extends InputStream
TheReplayInputStream
wraps anInputStream
addingmark(int)
,markSupported()
as well asreset()
functionality, similar to theBufferedInputStream
. In contrast to theBufferedInputStream
only the bytes actually read (by an application) are buffered, preventing it to hang as theBufferedInputStream
would do when it tries to load a buffer of predefined size from (e.g. a serial TTY/COM port)InputStream
which blocks till the requested data is actually available, making the whole application to "hang" (even though just one byte was to be read). TheReplayInputStream
always uses its ownmark(int)
,markSupported()
as well asreset()
implementations even if the wrappedInputStream
(such as theBufferedInputStream
supportsmark(int)
andreset()
!
-
-
Constructor Summary
Constructors Constructor Description ReplayInputStream(InputStream aInputStream)
-
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()
void
reset()
-
Methods inherited from class java.io.InputStream
nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
-
-
-
-
Constructor Detail
-
ReplayInputStream
public ReplayInputStream(InputStream aInputStream)
- Parameters:
aInputStream
- TheInputStream
to be decorated accordingly.
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
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
-
-