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
Constructors -
Method Summary
Methods inherited from class java.io.InputStream
nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
-
Constructor Details
-
ReplayInputStream
- Parameters:
aInputStream- TheInputStreamto be decorated accordingly.
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-