BytesWrittenResetOutputStreampublic class BytesWrittenResetOutputStream extends OutputStream 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 |
---|
OutputStream | outThe output stream wrapped by this method | private Watchdog | watchdogThe Watchdog to be reset every lengthReset bytes | int | lengthResetThe number of bytes that need to be written before the counter is reset. | int | writtenCounterThe number of bytes written since the counter was last reset |
Constructors Summary |
---|
public BytesWrittenResetOutputStream(OutputStream out, Watchdog watchdog, int lengthReset)
this.out = out;
this.watchdog = watchdog;
this.lengthReset = lengthReset;
writtenCounter = 0;
|
Methods Summary |
---|
public void | close()Close the stream
out.close();
| public void | flush()Flush the stream
out.flush();
| public void | write(byte[] b, int off, int len)Write an array of bytes to the stream
out.write(b, off, len);
writtenCounter += len;
if (writtenCounter > lengthReset) {
writtenCounter = 0;
watchdog.reset();
}
| public void | write(int b)Write a byte to the stream
out.write(b);
writtenCounter++;
if (writtenCounter > lengthReset) {
writtenCounter = 0;
watchdog.reset();
}
|
|