w.close();
// Get reader on said ARC.
WARCReader r = WARCReaderFactory.get(w.getFile());
final Iterator<ArchiveRecord> i = r.iterator();
// Skip first ARC meta record.
ArchiveRecord ar = i.next();
i.hasNext();
// Now we're at first and only record in ARC.
ar = (WARCRecord) i.next();
// Now try getting some random set of bytes out of it
// at an odd offset (used to fail because we were
// doing bad math to find where in buffer to read).
final byte[] buffer = new byte[17];
final int maxRead = 4;
int totalRead = 0;
while (totalRead < maxRead) {
totalRead = totalRead
+ ar.read(buffer, 13 + totalRead, maxRead - totalRead);
assertTrue(totalRead > 0);
}
}