本文整理匯總了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();
}
}