BytesReadResetInputStreampublic class BytesReadResetInputStream extends InputStream This will reset the Watchdog each time a certain amount of data has
been transferred. This allows us to keep the timeout settings low, while
not timing out during large data transfers. |
Fields Summary |
---|
private InputStream | inThe wrapped InputStream | private Watchdog | watchdogThe Watchdog to be reset every lengthReset bytes | private int | lengthResetThe number of bytes that need to be read before the counter is reset. | int | readCounterThe number of bytes read since the counter was last reset |
Constructors Summary |
---|
public BytesReadResetInputStream(InputStream in, Watchdog watchdog, int lengthReset)
this.in = in;
this.watchdog = watchdog;
this.lengthReset = lengthReset;
readCounter = 0;
|
Methods Summary |
---|
public void | close()Close the stream
in.close();
| public int | read(byte[] b, int off, int len)Read an array of bytes from the stream
int l = in.read(b, off, len);
readCounter += l;
if (readCounter > lengthReset) {
readCounter = 0;
watchdog.reset();
}
return l;
| public int | read()Read a byte from the stream
int b = in.read();
readCounter++;
if (readCounter > lengthReset) {
readCounter = 0;
watchdog.reset();
}
return b;
|
|