Package i2p.susi.util
Class EOFOnMatchInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.PushbackInputStream
i2p.susi.util.EOFOnMatchInputStream
- All Implemented Interfaces:
ReadCounter,Closeable,AutoCloseable
A stream that returns EOF when the input matches
the bytes provided. The reader will never see any bytes
from a full match.
We extend PushbackInputStream for convenience,
but we use its buffer as a fifo, not a stack.
Do not call the unread() methods externally.
- Since:
- 0.9.34
-
Field Summary
Fields inherited from class java.io.PushbackInputStream
buf, posFields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionEOFOnMatchInputStream(InputStream in, byte[] match) Non-counter mode.EOFOnMatchInputStream(InputStream in, ReadCounter ctr, byte[] match) Counter mode. -
Method Summary
Methods inherited from class java.io.PushbackInputStream
available, close, mark, markSupported, reset, unread, unread, unreadMethods inherited from class java.io.FilterInputStream
readMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
EOFOnMatchInputStream
Non-counter mode. getRead() will return 0.- Parameters:
match- will be copied
-
EOFOnMatchInputStream
Counter mode. getRead() will the ReadCounter's value, not including the match bytes.- Parameters:
match- will be copied
-
-
Method Details
-
getRead
public long getRead()If constructed with a counter, returns the count (not necessarily starting at 0) minus the buffered/matched count. Otherwise returns 0.- Specified by:
getReadin interfaceReadCounter
-
wasFound
public boolean wasFound()- Returns:
- true if we returned EOF because we hit the match
-
read
Debug only. Return the buffer.- Overrides:
readin classPushbackInputStream- Returns:
- the buffer
- Throws:
IOException
-
read
- Overrides:
readin classPushbackInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classPushbackInputStream- Throws:
IOException
-