// InputStream you can cut off at a certain byte // (to test streaming input) sclass SimulatedPartialInputStream extends InputStreamPlusReadFully { InputStream in; bool streamEnded; long position, cutOffPoint, mark; *(InputStream *in) {} public int read() throws IOException { if (streamEnded || streamPaused()) ret -1; int b = in.read(); if (b >= 0) ++position; else set streamEnded; ret b; } public void setCutOffPoint(long point) { cutOffPoint = point; } public bool streamPaused() { ret position >= cutOffPoint; } public bool streamEnded() { ret streamEnded; } public void incCutOffPoint(long bytes) { cutOffPoint += bytes; } @Override public bool markSupported() { true; } @Override public void mark(int readLimit) { mark = position; in.mark(readLimit); } @Override public void reset() throws IOException { if (mark < 0) fail(); position = mark; mark = -1; in.reset(); } toString { ret renderVars SimulatedPartialInputStream(+streamEnded, +position, +cutOffPoint, +mark); } }