private final int NUM_PASSES = 4;
public void test() throws IOException {
InputStream is = createTestInputStream();
RereadableInputStream ris = new RereadableInputStream(is,
MEMORY_THRESHOLD, true, true);
try {
for (int pass = 0; pass < NUM_PASSES; pass++) {
for (int byteNum = 0; byteNum < TEST_SIZE; byteNum++) {
int byteRead = ris.read();
assertEquals("Pass = " + pass + ", byte num should be "
+ byteNum + " but is " + byteRead + ".", byteNum,
byteRead);
}
ris.rewind();
}
} finally {
// The RereadableInputStream should close the original input
// stream (if it hasn't already).
ris.close();
}
}