本文整理了Java中java.util.zip.ZipEntry.getMethod()
方法的一些代码示例,展示了ZipEntry.getMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.getMethod()
方法的具体详情如下:
包路径:java.util.zip.ZipEntry
类名称:ZipEntry
方法名:getMethod
[英]Gets the compression method for this ZipEntry.
[中]获取此ZipEntry的压缩方法。
代码示例来源:origin: iBotPeaches/Apktool
@Override
public int getCompressionLevel(String fileName)
throws DirectoryException {
ZipEntry entry = getZipFileEntry(fileName);
return entry.getMethod();
}
代码示例来源:origin: pxb1988/dex2jar
@Override
public void putNextEntry(ZipEntry e) throws IOException {
if (e.getMethod() != ZipEntry.STORED) {
super.putNextEntry(e);
} else {
delayedEntry = e;
if (delayedOutputStream == null) {
delayedOutputStream = new AccessBufByteArrayOutputStream();
}
}
}
代码示例来源:origin: Tencent/tinker
private void getCompressMethodFromApk() {
ZipFile zipFile = null;
try {
zipFile = new ZipFile(config.mNewApkFile);
ArrayList<String> sets = new ArrayList<>();
sets.addAll(modifiedSet);
sets.addAll(addedSet);
ZipEntry zipEntry;
for (String name : sets) {
zipEntry = zipFile.getEntry(name);
if (zipEntry != null && zipEntry.getMethod() == ZipEntry.STORED) {
storedSet.add(name);
}
}
} catch (Throwable throwable) {
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e) {
}
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Writes data for the current entry to the underlying stream.
*
* @exception IOException
* If an error occurs writing to the stream
*/
@Override
public void write(byte[] buffer, int offset, int byteCount) throws IOException {
Arrays.checkOffsetAndCount(buffer.length, offset, byteCount);
if (currentEntry == null) {
throw new ZipException("No active entry");
}
if (currentEntry.getMethod() == STORED) {
out.write(buffer, offset, byteCount);
} else {
super.write(buffer, offset, byteCount);
}
crc.update(buffer, offset, byteCount);
}
代码示例来源:origin: google/j2objc
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
if(outEntry.getMethod() == ZipEntry.STORED){
CRC32 crc = new CRC32();
crc.update(bytes);
代码示例来源: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: zeroturnaround/zt-zip
/**
* Returns the compression method of a given entry of the ZIP file.
*
* @param zip
* ZIP file.
* @param name
* entry name.
* @return Returns <code>ZipEntry.STORED</code>, <code>ZipEntry.DEFLATED</code> or -1 if
* the ZIP file does not contain the given entry.
*/
public static int getCompressionMethodOfEntry(File zip, String name) {
ZipFile zf = null;
try {
zf = new ZipFile(zip);
ZipEntry zipEntry = zf.getEntry(name);
if (zipEntry == null) {
return -1;
}
return zipEntry.getMethod();
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
finally {
closeQuietly(zf);
}
}
代码示例来源:origin: org.easymock/easymock
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
if(outEntry.getMethod() == ZipEntry.STORED){
CRC32 crc = new CRC32();
crc.update(bytes);
代码示例来源:origin: cglib/cglib
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
if(outEntry.getMethod() == ZipEntry.STORED){
CRC32 crc = new CRC32();
crc.update(bytes);
代码示例来源:origin: cglib/cglib
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
if(outEntry.getMethod() == ZipEntry.STORED){
CRC32 crc = new CRC32();
crc.update(bytes);
代码示例来源:origin: robolectric/robolectric
FileMap createEntryFileMap(ZipEntryRO entry)
{
// final _ZipEntryRO *zipEntry = reinterpret_cast<_ZipEntryRO*>(entry);
// const ZipEntry& ze = zipEntry->entry;
ZipEntry ze = entry.entry;
// int fd = GetFileDescriptor(mHandle);
int fd = -1;
int actualLen = 0;
if (ze.getMethod() == kCompressStored) {
actualLen = toIntExact(ze.getSize());
} else {
actualLen = toIntExact(ze.getCompressedSize());
}
FileMap newMap = new FileMap();
if (!newMap.createFromZip(mFileName, mHandle.zipFile, entry.entry, actualLen, true)) {
// delete newMap;
return null;
}
return newMap;
}
代码示例来源: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: robolectric/robolectric
if (entry.entry.getMethod() == kCompressDeflated) {
代码示例来源: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
/**
* Creates a new zip entry with fields taken from the specified zip entry.
*
* <p>Assumes the entry represents a directory if and only if the
* name ends with a forward slash "/".</p>
*
* @param entry the entry to get fields from
* @since 1.1
* @throws ZipException on error
*/
public ZipEntry(final java.util.zip.ZipEntry entry) throws ZipException {
super(entry);
setName(entry.getName());
final byte[] extra = entry.getExtra();
if (extra != null) {
setExtraFields(ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils.UnparseableExtraField.READ));
} else {
// initializes extra data to an empty byte array
setExtra();
}
setMethod(entry.getMethod());
this.size = entry.getSize();
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Creates a new zip entry with fields taken from the specified zip entry.
*
* <p>Assumes the entry represents a directory if and only if the
* name ends with a forward slash "/".</p>
*
* @param entry the entry to get fields from
* @throws ZipException on error
*/
public ZipArchiveEntry(final java.util.zip.ZipEntry entry) throws ZipException {
super(entry);
setName(entry.getName());
final byte[] extra = entry.getExtra();
if (extra != null) {
setExtraFields(ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils
.UnparseableExtraField.READ));
} else {
// initializes extra data to an empty byte array
setExtra();
}
setMethod(entry.getMethod());
this.size = entry.getSize();
}
代码示例来源:origin: alibaba/mdrill
/**
* Creates a new zip entry with fields taken from the specified zip entry.
*
* <p>Assumes the entry represents a directory if and only if the
* name ends with a forward slash "/".</p>
*
* @param entry the entry to get fields from
* @since 1.1
* @throws ZipException on error
*/
public ZipEntry(java.util.zip.ZipEntry entry) throws ZipException {
super(entry);
setName(entry.getName());
byte[] extra = entry.getExtra();
if (extra != null) {
setExtraFields(ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils
.UnparseableExtraField.READ));
} else {
// initializes extra data to an empty byte array
setExtra();
}
setMethod(entry.getMethod());
this.size = entry.getSize();
}
代码示例来源:origin: robolectric/robolectric
if (entry.get().getMethod() == kCompressDeflated) {
System.out.println(kResourcesArsc + " in APK '" + path + "' is compressed.");
代码示例来源: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: robovm/robovm
return;
if (currentEntry.getMethod() == DEFLATED) {
super.finish();
if (currentEntry.getMethod() == STORED) {
if (crc.getValue() != currentEntry.crc) {
throw new ZipException("CRC mismatch");
if (currentEntry.getMethod() != STORED) {
curOffset += EXTHDR;
writeLong(out, EXTSIG);
int flags = currentEntry.getMethod() == STORED ? 0 : ZipFile.GPBF_DATA_DESCRIPTOR_FLAG;
writeShort(cDir, currentEntry.getMethod());
writeShort(cDir, currentEntry.time);
writeShort(cDir, currentEntry.modDate);
writeLong(cDir, crc.getValue());
if (currentEntry.getMethod() == DEFLATED) {
curOffset += writeLong(cDir, def.getTotalOut());
writeLong(cDir, def.getTotalIn());
内容来源于网络,如有侵权,请联系作者删除!