當前位置: 首頁>>代碼示例>>Java>>正文


Java ZipEntry.getMethod方法代碼示例

本文整理匯總了Java中java.util.zip.ZipEntry.getMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipEntry.getMethod方法的具體用法?Java ZipEntry.getMethod怎麽用?Java ZipEntry.getMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.zip.ZipEntry的用法示例。


在下文中一共展示了ZipEntry.getMethod方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeEntry

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:JarSigner.java

示例2: unzipApk

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
public static List<String> unzipApk(String fileName, String filePath)
        throws IOException {
    FileUtils.checkDirectory(filePath);

    List<String> storedFiles = new ArrayList<>();
    ZipFile zipFile = new ZipFile(fileName);
    Enumeration em = zipFile.entries();
    while (em.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) em.nextElement();
        if (entry.isDirectory()) {
            new File(filePath, entry.getName()).mkdirs();
        } else {
            File file = new File(filePath + File.separator + entry.getName());
            File parent = file.getParentFile();
            if ((parent != null) && (!parent.exists())) {
                parent.mkdirs();
            }
            if (entry.getMethod() == 0) {
                storedFiles.add(entry.getName());
            }
            BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
            FileOutputStream fos = new FileOutputStream(file);
            BufferedOutputStream bos = new BufferedOutputStream(fos, 8192);

            byte[] buf = new byte[BUFFER];
            int len;
            while ((len = bis.read(buf, 0, 8192)) != -1) {
                fos.write(buf, 0, len);
            }
            bos.flush();
            bos.close();
            bis.close();
        }
    }
    zipFile.close();
    return storedFiles;
}
 
開發者ID:CankingApp,項目名稱:apk-shrink,代碼行數:38,代碼來源:ApkUtils.java

示例3: writeEntry

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
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();
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:15,代碼來源:ZipUpdater.java

示例4: getCompressionLevel

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
@Override
public int getCompressionLevel(String fileName)
        throws DirectoryException {
    ZipEntry entry =  mZipFile.getEntry(fileName);
    if (entry == null) {
        throw new PathNotExist("Entry not found: " + fileName);
    }
    return entry.getMethod();
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:10,代碼來源:ZipRODirectory.java

示例5: writeZip

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
/**
 * Copies the content of a Jar/Zip archive into the receiver archive.
 * <p/>An optional {@link IZipEntryFilter} allows to selectively choose which files
 * to copy over.
 *
 * @param input  the {@link InputStream} for the Jar/Zip to copy.
 * @param filter the filter or <code>null</code>
 * @throws IOException
 */
public void writeZip(InputStream input, IZipEntryFilter filter)
        throws IOException, IZipEntryFilter.ZipAbortException {
    ZipInputStream zis = new ZipInputStream(input);
    try {
        // loop on the entries of the intermediary package and put them in the final package.
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            // do not take directories or anything inside a potential META-INF folder.
            if (entry.isDirectory() || name.startsWith("META-INF/")) {
                continue;
            }
            // if we have a filter, we check the entry against it
            if (filter != null && filter.checkEntry(name) == false) {
                continue;
            }
            JarEntry newEntry;
            // Preserve the STORED method of the input entry.
            if (entry.getMethod() == JarEntry.STORED) {
                newEntry = new JarEntry(entry);
            } else {
                // Create a new entry so that the compressed len is recomputed.
                newEntry = new JarEntry(name);
            }
            writeEntry(zis, newEntry);
            zis.closeEntry();
        }
    } finally {
        zis.close();
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:41,代碼來源:SignedJarBuilder.java

示例6: zeString

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
static String zeString(ZipEntry ze) {
    int store = (ze.getCompressedSize() > 0) ?
        (int)( (1.0 - ((double)ze.getCompressedSize()/(double)ze.getSize()))*100 )
        : 0 ;
    // Follow unzip -lv output
    return ze.getSize() + "\t" + ze.getMethod()
        + "\t" + ze.getCompressedSize() + "\t"
        + store + "%\t"
        + new Date(ze.getTime()) + "\t"
        + Long.toHexString(ze.getCrc()) + "\t"
        + ze.getName() ;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:Utils.java


注:本文中的java.util.zip.ZipEntry.getMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。