// Run with an arg to create a test file that can be used to figure // out what position in the data stream can be changed. if (args.length > 0) {
FileOutputStream fos = new FileOutputStream("stored.zip");
fos.write(data, 0, data.length);
fos.close();
} else { // Test that reading byte-at-a-time works
ZipInputStream zis = new ZipInputStream( new ByteArrayInputStream(data));
ze = zis.getNextEntry(); int pos = 0; byte[] readData = newbyte[256]; try { int count = zis.read(readData, pos, 1); while (count > 0) {
count = zis.read(readData, ++pos, 1);
}
check(writtenString.equals(new String(readData, 0, pos, "ASCII")));
} catch (Throwable t) {
unexpected(t);
}
// Test that data corruption is detected. "offset" was // determined to be in the entry's uncompressed data.
data[getDataOffset(data) + 4] ^= 1;
zis = new ZipInputStream( new ByteArrayInputStream(data));
ze = zis.getNextEntry();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.