java.lang.Object
java.io.InputStream
org.refcodes.io.ReplayInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
The
ReplayInputStream
wraps an InputStream
adding
mark(int)
, markSupported()
as well as reset()
functionality, similar to the BufferedInputStream
.
In contrast to the BufferedInputStream
only the bytes actually read
(by an application) are buffered, preventing it to hang as the
BufferedInputStream
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).
The ReplayInputStream
always uses its own mark(int)
,
markSupported()
as well as reset()
implementations even if
the wrapped InputStream
(such as the BufferedInputStream
supports mark(int)
and reset()
!-
Constructor Summary
-
Method Summary
Methods inherited from class java.io.InputStream
nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
-
Constructor Details
-
ReplayInputStream
- Parameters:
aInputStream
- TheInputStream
to be decorated accordingly.
-
-
Method Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- 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
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-