Package mireka.filter.misc
Class ThresholdingInputStream
- Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- mireka.filter.misc.ThresholdingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,AutoCloseable
public abstract class ThresholdingInputStream extends java.io.FilterInputStream
-
-
Constructor Summary
Constructors Constructor Description ThresholdingInputStream(java.io.InputStream in, int thresholdBytes)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckThreshold()Checks whether reading count bytes would cross the limit.intgetThreshold()voidmark(int readlimit)intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()longskip(long n)protected abstract voidthresholdReached(int current)Called when the threshold is about to be exceeded.
-
-
-
Method Detail
-
mark
public void mark(int readlimit)
- Overrides:
markin classjava.io.FilterInputStream
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
checkThreshold
protected void checkThreshold() throws java.io.IOExceptionChecks whether reading count bytes would cross the limit.- Throws:
java.io.IOException
-
getThreshold
public int getThreshold()
- Returns:
- the current threshold value.
-
thresholdReached
protected abstract void thresholdReached(int current) throws java.io.IOExceptionCalled when the threshold is about to be exceeded. This isn't exact; it's called whenever a write would occur that would cross the amount. Once it is called, it isn't called again.- Parameters:
current- is the current number of bytes that have been written- Throws:
java.io.IOException
-
-