// Zip entry names to create a Zip file with for validating they are not // interpreted as a "." or ".." entry privatefinal String[] VALID_PATHS =
{"/foo.txt", "/..foo.txt", "/.foo.txt", "/.foo/bar.txt", "/foo/bar.txt"}; // Paths to be returned from Files::walk via Zip FS privatefinal String[] EXPECTED_PATHS =
{"/", "/..foo.txt", "/foo.txt", "/.foo.txt", "/.foo", "/.foo/bar.txt", "/foo/bar.txt", "/foo"};
/** *CreatesaZipfile *@paramzippathforZiptobecreated *@paramentriestheentriestoaddtotheZipfile *@throwsIOExceptionifanerroroccurs
*/ privatestaticvoid createZip(Path zip, String... entries) throws IOException { try (var os = Files.newOutputStream(zip);
ZipOutputStream zos = new ZipOutputStream(os)) { for (var e : entries) { var ze = new ZipEntry(e); var crc = new CRC32();
ze.setMethod(ZipEntry.STORED);
crc.update(ENTRY_DATA);
ze.setCrc(crc.getValue());
ze.setSize(ENTRY_DATA.length);
zos.putNextEntry(ze);
zos.write(ENTRY_DATA);
}
}
}
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.