privatestaticfinalint BUFFER_SIZE = 2048; // ZIP file to create privatestaticfinal String ZIP_FILE_NAME = "Zip64SizeTest.zip"; // File that will be created with a size greater than 0xFFFFFFFF privatestaticfinal String LARGE_FILE_NAME = "LargeZipEntry.txt"; // File that will be created with a size less than 0xFFFFFFFF privatestaticfinal String SMALL_FILE_NAME = "SmallZipEntry.txt"; // List of files to be added to the ZIP file privatestaticfinal List<String> ZIP_ENTRIES = List.of(LARGE_FILE_NAME,
SMALL_FILE_NAME); privatestaticfinallong LARGE_FILE_SIZE = 5L * 1024L * 1024L * 1024L; // 5GB privatestaticfinallong SMALL_FILE_SIZE = 0x100000L; // 1024L x 1024L;
/** *ValidatethatifthesizeofaZIPentryexceeds0xFFFFFFFF,thatthe *correctsizeisreturnedfromtheZIP64Extendedinformation. *@throwsIOException
*/
@Test privatestaticvoid validateZipEntrySizes() throws IOException {
createFiles();
createZipFile();
System.out.println("Validating Zip Entry Sizes"); try (ZipFile zip = new ZipFile(ZIP_FILE_NAME)) {
ZipEntry ze = zip.getEntry(LARGE_FILE_NAME);
System.out.printf("Entry: %s, size= %s%n", ze.getName(), ze.getSize());
assertTrue(ze.getSize() == LARGE_FILE_SIZE);
ze = zip.getEntry(SMALL_FILE_NAME);
System.out.printf("Entry: %s, size= %s%n", ze.getName(), ze.getSize());
assertTrue(ze.getSize() == SMALL_FILE_SIZE);
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.