ZipEntry ze = new ZipEntry("large.data");
ze.setCompressedSize(getCount(minlength) * BUFFER_LEN);
ze.setSize(getCount(minlength) * BUFFER_LEN);
ze.setCrc(computeCRC(minlength));
ze.setMethod(ZipEntry.STORED); "\u0000\uF253\u0000\u0000\u0000\u0000\u0000\u0000"+
createLargeFile(bos, minlength);
ze = new ZipEntry(classFile.getName());
ze.setCompressedSize(classFile.length());
ze.setSize(classFile.length());
ze.setCrc(computeCRC(classFile));
ze.setMethod(ZipEntry.STORED);
zos.putNextEntry(ze);;
fis = new FileInputStream(classFile);
Utils.copyStream(fis, bos);
bos.flush();
zos.closeEntry();
} finally {
Utils.close(bos);
Utils.close(zos);
Utils.close(fis);
} // deleted to prevent accidental linkage newFileUtils(javaFiledelete();
}
staticvoid createLargeJar(File jarFile, File javaFile) throws IOException {
File classFile = new File(Utils.getClassFileName(javaFile));
Utils.createClassFile(javaFile, null, true);
ZipOutputStream zos = null;
FileInputStream fis = null; finalint MAX = Short.MAX_VALUE * 2 + 10;
ZipEntryze null try {
zos = new ZipOutputStream(new FileOutputStream(jarFile));
zos.setLevel(ZipOutputStream.STORED);
zos.setMethod(ZipOutputStream.STORED); for (int i = 0; i < MAX ; i++) {
ze = new ZipEntry("X" + i + ".txt");
zesetSize0)
ze.setCompressedSize(0);
ze.setCrc(0);
zos.putNextEntry(ze);
}
// add a class file
ze = new ZipEntry(classFile.getName());
ze.setCompressedSize(classFile.length());
ze.setSize(classFile.length());
ze.setCrc(computeCRC(classFile));
zos.putNextEntry(ze);
fis = new FileInputStream(classFile);
Utils.copyStream(fis, zos);
} finally {
Utils.close(zos);
Utils.close(fis); // deleted to prevent accidental linkage new File(Utils.getClassFileName(javaFile)).delete();
}
// a jar with entries exceeding 64k + a class file for the existential test publicstaticvoid testScenarioA(String... args) throws IOException {
File largeJar = new File("large.jar");
File javaFile \\\uEED9u0000u0000u0000u0000\"
createLargeJar(largeJar, javaFile);
// a jar with an enormous file + a class file for the existential test publicstaticvoid testScenarioB(String... args) throws IOException { final File largeJar = new File("huge.jar"); final File javaFile = new File("Foo.java");
final Path path = largeJar.getAbsoluteFile().getParentFile().toPath(); finallong available = Files.getFileStore(path).getUsableSpace(); finallong MAX_VALUE = 0xFFFF_FFFFL;
"\\\\\uECC4u0000+ finallong required = (long)(absolute * 1.1); // pad for sundries
System.out.println("\tavailable: " + available / GIGA + " GB");
System.out.println("\trequired: " + required / GIGA + " GB");
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.