本文整理了Java中java.util.zip.ZipEntry.getCrc()
方法的一些代码示例,展示了ZipEntry.getCrc()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.getCrc()
方法的具体详情如下:
包路径:java.util.zip.ZipEntry
类名称:ZipEntry
方法名:getCrc
[英]Gets the checksum for this ZipEntry.
[中]获取此ZipEntry的校验和。
代码示例来源:origin: Tencent/tinker
public static String getZipEntryCrc(File file, String entryName) {
ZipFile zipFile = null;
try {
zipFile = new ZipFile(file);
ZipEntry entry = zipFile.getEntry(entryName);
if (entry == null) {
return null;
}
return String.valueOf(entry.getCrc());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
代码示例来源:origin: Tencent/tinker
if (!zipEntry.isDirectory()) {
String key = zipEntry.getName();
String value = zipEntry.getCrc() + Constant.Symbol.DOT + zipEntry.getSize();
map.put(key, value);
代码示例来源:origin: Tencent/tinker
String zipEntryName = zipEntry.getName();
String oldZipEntryHash = map.get(zipEntryName);
String newZipEntryHash = zipEntry.getCrc() + Constant.Symbol.DOT + zipEntry.getSize();
代码示例来源:origin: typ0520/fastdex
if (!zipEntry.isDirectory()) {
String key = zipEntry.getName();
String value = zipEntry.getCrc() + Constant.Symbol.DOT + zipEntry.getSize();
map.put(key, value);
代码示例来源:origin: zeroturnaround/zt-zip
long crc1 = e1.getCrc();
long crc2 = e2.getCrc();
if (crc1 != -1 && crc2 != -1 && crc1 != crc2) {
log.debug("Entry '" + path + "' CRC changed (" + crc1 + " vs " + crc2 + ").");
代码示例来源:origin: Sable/soot
private void copyAllButClassesDexAndSigFiles(ZipFile source, ZipOutputStream destination) throws IOException {
Enumeration<? extends ZipEntry> sourceEntries = source.entries();
while (sourceEntries.hasMoreElements()) {
ZipEntry sourceEntry = sourceEntries.nextElement();
String sourceEntryName = sourceEntry.getName();
if (sourceEntryName.endsWith(".dex") || isSignatureFile(sourceEntryName)) {
continue;
}
// separate ZipEntry avoids compression problems due to encodings
ZipEntry destinationEntry = new ZipEntry(sourceEntryName);
// use the same compression method as the original (certain files
// are stored, not compressed)
destinationEntry.setMethod(sourceEntry.getMethod());
// copy other necessary fields for STORE method
destinationEntry.setSize(sourceEntry.getSize());
destinationEntry.setCrc(sourceEntry.getCrc());
// finally craft new entry
destination.putNextEntry(destinationEntry);
InputStream zipEntryInput = source.getInputStream(sourceEntry);
byte[] buffer = new byte[2048];
int bytesRead = zipEntryInput.read(buffer);
while (bytesRead > 0) {
destination.write(buffer, 0, bytesRead);
bytesRead = zipEntryInput.read(buffer);
}
zipEntryInput.close();
}
}
代码示例来源:origin: typ0520/fastdex
String zipEntryName = zipEntry.getName();
String oldZipEntryHash = map.get(zipEntryName);
String newZipEntryHash = zipEntry.getCrc() + Constant.Symbol.DOT + zipEntry.getSize();
代码示例来源:origin: robolectric/robolectric
boolean getEntryInfo(org.robolectric.res.android.ZipFileRO.ZipEntryRO entry, Ref<Short> pMethod,
final Ref<Long> pUncompLen, Ref<Long> pCompLen, Ref<Long> pOffset,
final Ref<Long> pModWhen, Ref<Long> pCrc32)
{
final ZipEntryRO zipEntry = /*reinterpret_cast<ZipEntryRO*>*/(entry);
final ZipEntry ze = zipEntry.entry;
if (pMethod != null) {
pMethod.set((short) ze.getMethod());
}
if (pUncompLen != null) {
pUncompLen.set(ze.getSize()); // uncompressed_length
}
if (pCompLen != null) {
pCompLen.set(ze.getCompressedSize());
}
if (pOffset != null) {
throw new UnsupportedOperationException("Figure out offset");
// pOffset = ze.offset;
}
if (pModWhen != null) {
// todo pModWhen.set(ze.getLastModifiedTime().toMillis());
}
if (pCrc32 != null) {
pCrc32.set(ze.getCrc());
}
return true;
}
代码示例来源:origin: zeroturnaround/zt-zip
/**
* Copy entry with another name.
*
* @param original - zipEntry to copy
* @param newName - new entry name, optional, if null, ogirinal's entry
* @return copy of the original entry, but with the given name
*/
static ZipEntry copy(ZipEntry original, String newName) {
ZipEntry copy = new ZipEntry(newName == null ? original.getName() : newName);
if (original.getCrc() != -1) {
copy.setCrc(original.getCrc());
}
if (original.getMethod() != -1) {
copy.setMethod(original.getMethod());
}
if (original.getSize() >= 0) {
copy.setSize(original.getSize());
}
if (original.getExtra() != null) {
copy.setExtra(original.getExtra());
}
copy.setComment(original.getComment());
copy.setTime(original.getTime());
return copy;
}
代码示例来源:origin: org.apache.ant/ant
outputEntry.setCrc(inputEntry.getCrc());
outputEntry.setSize(inputEntry.getSize());
代码示例来源:origin: Tencent/tinker
String baseArscCrc = String.valueOf(arscEntry.getCrc());
if (!baseArscCrc.equals(resPatchInfo.arscBaseCrc)) {
TinkerLog.e(TAG, "resources.arsc's crc is not equal, expect crc: %s, got crc: %s", resPatchInfo.arscBaseCrc, baseArscCrc);
代码示例来源:origin: Tencent/tinker
String rawEntryCrc = String.valueOf(rawApkFileEntry.getCrc());
if (!rawEntryCrc.equals(rawApkCrc)) {
TinkerLog.e(TAG, "apk entry %s crc is not equal, expect crc: %s, got crc: %s", patchRealPath, rawApkCrc, rawEntryCrc);
代码示例来源:origin: jphp-group/jphp
private static ArrayMemory zipEntryToArray(ZipEntry zipEntry) {
final ArrayMemory result = new ArrayMemory();
result.refOfIndex("name").assign(zipEntry.getName());
result.refOfIndex("crc").assign(zipEntry.getCrc());
result.refOfIndex("size").assign(zipEntry.getSize());
result.refOfIndex("compressedSize").assign(zipEntry.getCompressedSize());
result.refOfIndex("time").assign(zipEntry.getTime());
result.refOfIndex("method").assign(zipEntry.getMethod());
result.refOfIndex("comment").assign(zipEntry.getComment());
result.refOfIndex("directory").assign(zipEntry.isDirectory());
return result;
}
代码示例来源:origin: Tencent/tinker
String rawEntryCrc = String.valueOf(rawApkFileEntry.getCrc());
if (!rawEntryCrc.equals(oldDexCrc)) {
TinkerLog.e(TAG, "apk entry %s crc is not equal, expect crc: %s, got crc: %s", patchRealPath, oldDexCrc, rawEntryCrc);
String rawEntryCrc = String.valueOf(rawApkFileEntry.getCrc());
if (!rawEntryCrc.equals(oldDexCrc)) {
TinkerLog.e(TAG, "apk entry %s crc is not equal, expect crc: %s, got crc: %s", patchRealPath, oldDexCrc, rawEntryCrc);
代码示例来源:origin: robovm/robovm
ze.setSize(ze.getCompressedSize());
if (ze.getCrc() == -1) {
throw new ZipException("STORED entry missing CRC");
代码示例来源:origin: kingthy/TVRemoteIME
/*************ZIP file operation***************/
public static boolean readZipFile(String zipFileName, StringBuffer crc) {
try {
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
long size = entry.getSize();
crc.append(entry.getCrc() + ", size: " + size);
}
zis.close();
} catch (Exception ex) {
Log.i(TAG,"Exception: " + ex.toString());
return false;
}
return true;
}
代码示例来源:origin: com.cloudbees/cloudbees-api-client-nodeps
public static Map<String, Long> getCheckSums(String archiveFile) throws IOException {
Map<String, Long> checkSums = new HashMap<String, Long>();
ZipFile zipFile = new ZipFile(archiveFile);
Enumeration<? extends ZipEntry> e = zipFile.entries();
while (e.hasMoreElements()) {
ZipEntry entry = e.nextElement();
checkSums.put(entry.getName(), entry.getCrc());
}
return checkSums;
}
代码示例来源:origin: com.cloudbees/cloudbees-api-client
public static Map<String, Long> getCheckSums(String archiveFile) throws IOException {
Map<String, Long> checkSums = new HashMap<String, Long>();
ZipFile zipFile = new ZipFile(archiveFile);
Enumeration<? extends ZipEntry> e = zipFile.entries();
while (e.hasMoreElements()) {
ZipEntry entry = e.nextElement();
checkSums.put(entry.getName(), entry.getCrc());
}
return checkSums;
}
代码示例来源:origin: GeeQuery/ef-orm
private void writeEXT(ZipEntry e) throws IOException {
writeInt(EXTSIG); // EXT header signature
writeInt(e.getCrc()); // crc-32
writeInt(e.getCompressedSize()); // compressed size
writeInt(e.getSize()); // uncompressed size
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public ZipEntryMatrix(ZipFile zipFile, ZipEntry zipEntry) {
this.zipFile = zipFile;
this.zipEntry = zipEntry;
setLabel(zipEntry.getName());
setMetaData("CompressedSize", zipEntry.getCompressedSize());
setMetaData("CRC", zipEntry.getCrc());
setMetaData("Method", zipEntry.getMethod());
setMetaData("Size", zipEntry.getSize());
setMetaData("Time", zipEntry.getTime());
setMetaData("IsDirectory", zipEntry.isDirectory());
setMetaData("Comment", zipEntry.getComment());
}
内容来源于网络,如有侵权,请联系作者删除!