本文整理汇总了Java中java.util.zip.ZipEntry.STORED属性的典型用法代码示例。如果您正苦于以下问题:Java ZipEntry.STORED属性的具体用法?Java ZipEntry.STORED怎么用?Java ZipEntry.STORED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.zip.ZipEntry
的用法示例。
在下文中一共展示了ZipEntry.STORED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeEntry
private void writeEntry(ZipFile zf, ZipOutputStream os, ZipEntry ze)
throws IOException {
ZipEntry ze2 = new ZipEntry(ze.getName());
ze2.setMethod(ze.getMethod());
ze2.setTime(ze.getTime());
ze2.setComment(ze.getComment());
ze2.setExtra(ze.getExtra());
if (ze.getMethod() == ZipEntry.STORED) {
ze2.setSize(ze.getSize());
ze2.setCrc(ze.getCrc());
}
os.putNextEntry(ze2);
writeBytes(zf, ze, os);
}
示例2: writeEntry
private long writeEntry(InputStream zis, ZipOutputStream output, ZipEntry newEntry) throws IOException {
// FIXME: is there a better way to do this, so that the whole input
// stream isn't in memory at once?
final byte[] contents = IOUtils.toByteArray(zis);
final CRC32 checksum = new CRC32();
checksum.update(contents);
if (newEntry.getMethod() == ZipEntry.STORED) {
newEntry.setSize(contents.length);
newEntry.setCrc(checksum.getValue());
}
output.putNextEntry(newEntry);
output.write(contents, 0, contents.length);
return checksum.getValue();
}
示例3: copyUnknownFiles
private void copyUnknownFiles(File appDir, ZipOutputStream outputFile, Map<String, String> files)
throws 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, 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();
}
}