- java.lang.Object
-
- java.io.InputStream
-
- org.refcodes.io.ReplayInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ReplayInputStream extends InputStream
TheReplayInputStreamwraps anInputStreamaddingmark(int),markSupported()as well asreset()functionality, similar to theBufferedInputStream. In contrast to theBufferedInputStreamonly the bytes actually read (by an application) are buffered, preventing it to hang as theBufferedInputStreamwould do when it tries to load a buffer of predefined size from (e.g. a serial TTY/COM port)InputStreamwhich blocks till the requested data is actually available, making the whole application to "hang" (even though just one byte was to be read). TheReplayInputStreamalways uses its ownmark(int),markSupported()as well asreset()implementations even if the wrappedInputStream(such as theBufferedInputStreamsupportsmark(int)andreset()!
-
-
Constructor Summary
Constructors Constructor Description ReplayInputStream(InputStream aInputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()voidmark(int readlimit)booleanmarkSupported()intread()voidreset()-
Methods inherited from class java.io.InputStream
nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
-
-
-
-
Constructor Detail
-
ReplayInputStream
public ReplayInputStream(InputStream aInputStream)
- Parameters:
aInputStream- TheInputStreamto be decorated accordingly.
-
-
Method Detail
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
available
public int available() throws IOException- Overrides:
availablein classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classInputStream
-
reset
public void reset() throws IOException- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classInputStream
-
-