本文整理了Java中java.util.zip.ZipEntry.setCompressedSize()
方法的一些代码示例,展示了ZipEntry.setCompressedSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.setCompressedSize()
方法的具体详情如下:
包路径:java.util.zip.ZipEntry
类名称:ZipEntry
方法名:setCompressedSize
[英]Sets the compressed size for this ZipEntry.
[中]设置此ZipEntry的压缩大小。
代码示例来源:origin: iBotPeaches/Apktool
private void copyExistingFiles(ZipFile inputFile, ZipOutputStream outputFile) throws IOException {
// First, copy the contents from the existing outFile:
Enumeration<? extends ZipEntry> entries = inputFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = new ZipEntry(entries.nextElement());
// We can't reuse the compressed size because it depends on compression sizes.
entry.setCompressedSize(-1);
outputFile.putNextEntry(entry);
// No need to create directory entries in the final apk
if (! entry.isDirectory()) {
BrutIO.copy(inputFile, outputFile, entry);
}
outputFile.closeEntry();
}
}
代码示例来源:origin: iBotPeaches/Apktool
private void copyUnknownFiles(File appDir, ZipOutputStream outputFile, Map<String, String> files)
throws BrutException, IOException {
File unknownFileDir = new File(appDir, UNK_DIRNAME);
// loop through unknown files
for (Map.Entry<String,String> unknownFileInfo : files.entrySet()) {
File inputFile = new File(unknownFileDir, BrutIO.sanitizeUnknownFile(unknownFileDir, unknownFileInfo.getKey()));
if (inputFile.isDirectory()) {
continue;
}
ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey());
int method = Integer.parseInt(unknownFileInfo.getValue());
LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method));
if (method == ZipEntry.STORED) {
newEntry.setMethod(ZipEntry.STORED);
newEntry.setSize(inputFile.length());
newEntry.setCompressedSize(-1);
BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile));
CRC32 crc = BrutIO.calculateCrc(unknownFile);
newEntry.setCrc(crc.getValue());
} else {
newEntry.setMethod(ZipEntry.DEFLATED);
}
outputFile.putNextEntry(newEntry);
BrutIO.copy(inputFile, outputFile);
outputFile.closeEntry();
}
}
代码示例来源:origin: pxb1988/dex2jar
@Override
public void closeEntry() throws IOException {
ZipEntry delayedEntry = this.delayedEntry;
if (delayedEntry != null) {
AccessBufByteArrayOutputStream delayedOutputStream = this.delayedOutputStream;
byte[] buf = delayedOutputStream.getBuf();
int size = delayedOutputStream.size();
delayedEntry.setSize(size);
delayedEntry.setCompressedSize(size);
crc.reset();
crc.update(buf, 0, size);
delayedEntry.setCrc(crc.getValue());
super.putNextEntry(delayedEntry);
super.write(buf, 0, size);
this.delayedEntry = null;
delayedOutputStream.reset();
}
super.closeEntry();
}
代码示例来源:origin: guoguibing/librec
ZipEntry entry = new ZipEntry(file.getName());
entry.setMethod(ZipEntry.STORED);
entry.setCompressedSize(file.length());
entry.setSize(file.length());
entry.setCrc(crc.getValue());
代码示例来源:origin: google/j2objc
crc.update(bytes);
outEntry.setCrc( crc.getValue() );
outEntry.setCompressedSize(bytes.length);
代码示例来源:origin: iBotPeaches/Apktool
manifestCrc.update(manifest);
entry.setSize(manifest.length);
entry.setCompressedSize(-1);
entry.setCrc(manifestCrc.getValue());
out.putNextEntry(entry);
代码示例来源:origin: org.easymock/easymock
crc.update(bytes);
outEntry.setCrc( crc.getValue() );
outEntry.setCompressedSize(bytes.length);
代码示例来源:origin: cglib/cglib
crc.update(bytes);
outEntry.setCrc( crc.getValue() );
outEntry.setCompressedSize(bytes.length);
代码示例来源:origin: cglib/cglib
crc.update(bytes);
outEntry.setCrc( crc.getValue() );
outEntry.setCompressedSize(bytes.length);
代码示例来源:origin: robovm/robovm
ze.setCompressedSize(ze.getSize());
} else if (ze.getSize() == -1) {
ze.setSize(ze.getCompressedSize());
代码示例来源:origin: robovm/robovm
currentEntry.setCrc(ceCrc);
currentEntry.setSize(ceSize);
currentEntry.setCompressedSize(ceCompressedSize);
代码示例来源:origin: jamesagnew/hapi-fhir
public void addMimeTypeFile(String statedPath, String actualPath) throws IOException {
// byte data[] = new byte[BUFFER];
CRC32 crc = new CRC32();
// FileInputStream fi = new FileInputStream(actualPath);
// BufferedInputStream origin = new BufferedInputStream(fi, BUFFER);
out.setLevel(0);
ZipEntry entry = new ZipEntry(statedPath);
entry.setExtra(null);
names.add(statedPath);
String contents = "application/epub+zip";
crc.update(contents.getBytes());
entry.setCompressedSize(contents.length());
entry.setSize(contents.length());
entry.setCrc(crc.getValue());
entry.setMethod(ZipEntry.STORED);
out.putNextEntry(entry);
// int count;
// while ((count = origin.read(data, 0, BUFFER)) != -1) {
// out.write(data, 0, count);
// }
// origin.close();
out.write(contents.getBytes(),0,contents.length());
out.setLevel(Deflater.BEST_COMPRESSION);
}
代码示例来源:origin: google/bundletool
byte[] entryData = ByteStreams.toByteArray(is);
zipEntry.setSize(entryData.length);
zipEntry.setCompressedSize(entryData.length);
zipEntry.setCrc(computeCrc32(entryData));
outZip.putNextEntry(zipEntry);
代码示例来源:origin: open-eid/digidoc4j
private static ZipEntry getAsicMimeTypeZipEntry(byte[] mimeTypeBytes) {
ZipEntry entryMimetype = new ZipEntry(ZIP_ENTRY_MIMETYPE);
entryMimetype.setMethod(ZipEntry.STORED);
entryMimetype.setSize(mimeTypeBytes.length);
entryMimetype.setCompressedSize(mimeTypeBytes.length);
CRC32 crc = new CRC32();
crc.update(mimeTypeBytes);
entryMimetype.setCrc(crc.getValue());
return entryMimetype;
}
代码示例来源:origin: arhs/sd-dss
private ZipEntry getZipEntryMimeType(final byte[] mimeTypeBytes) {
final ZipEntry entryMimetype = new ZipEntry(ZIP_ENTRY_MIMETYPE);
entryMimetype.setMethod(ZipEntry.STORED);
entryMimetype.setSize(mimeTypeBytes.length);
entryMimetype.setCompressedSize(mimeTypeBytes.length);
final CRC32 crc = new CRC32();
crc.update(mimeTypeBytes);
entryMimetype.setCrc(crc.getValue());
return entryMimetype;
}
代码示例来源:origin: com.github.bloodshura/ignitium-core
public void setCompressedSize(@Nonnull Bytes size) {
getHandle().setCompressedSize(size.getB());
}
代码示例来源:origin: stackoverflow.com
private void writeMimeType(ZipOutputStream zip) throws IOException {
byte[] content = "application/epub+zip".getBytes("UTF-8");
ZipEntry entry = new ZipEntry("mimetype");
entry.setMethod(ZipEntry.STORED);
entry.setSize(20);
entry.setCompressedSize(20);
entry.setCrc(0x2CAB616F); // pre-computed
zip.putNextEntry(entry);
zip.write(content);
zip.closeEntry();
}
代码示例来源:origin: com.github.bloodshura/shurax
public void setCompressedSize(@Nonnull Bytes size) {
getHandle().setCompressedSize(size.getB());
}
代码示例来源:origin: io.github.jiri-meluzin/io.github.jiri-meluzin.tibcobwutils.earcomparer
public void updateFile(Path outputPath, List<T.V3<String, byte[], ZipEntry>> files) {
try (ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(outputPath.toFile()))) {
for (V3<String, byte[], ZipEntry> v : files) {
ZipEntry zipEntry = (ZipEntry)v.getC().clone();
zipEntry.setCompressedSize(-1);
zipEntry.setSize(v.getB().length);
zipFile.putNextEntry(zipEntry);
zipFile.write(v.getB());
}
} catch (IOException e) {
throw new RuntimeException("Cannot store zip file ("+outputPath+")" + e.getMessage(), e);
}
}
public static Comparator<? super V2<String, byte[]>> fileListComparator() {
代码示例来源:origin: net.java.trueupdate/trueupdate-core
/** Returns an output stream for writing the ZIP entry contents. */
@Override public OutputStream output() throws IOException {
if (directory()) {
entry.setMethod(ZipOutputStream.STORED);
entry.setSize(0);
entry.setCompressedSize(0);
entry.setCrc(0);
}
return output.stream(entry);
}
}
内容来源于网络,如有侵权,请联系作者删除!