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


Java ZipEntry.setExtra方法代碼示例

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


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

示例1: cloneEntry

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
private ZipEntry cloneEntry(ZipEntry entry) {
    ZipEntry newEntry = new ZipEntry(entry.getName());

    newEntry.setTime(entry.getTime());
    if (entry.getCreationTime() != null) {
        newEntry.setCreationTime(entry.getCreationTime());
    }
    if (entry.getLastModifiedTime() != null) {
        newEntry.setLastModifiedTime(entry.getLastModifiedTime());
    }
    if (entry.getLastAccessTime() != null) {
        newEntry.setLastAccessTime(entry.getLastAccessTime());
    }
    newEntry.setComment(entry.getComment());
    newEntry.setExtra(entry.getExtra());

    return newEntry;
}
 
開發者ID:docbleach,項目名稱:DocBleach,代碼行數:19,代碼來源:ArchiveBleach.java

示例2: 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

示例3: readEntry

import java.util.zip.ZipEntry; //導入方法依賴的package包/類
static ZipEntry readEntry(ByteBuffer in) throws IOException {

        int sig = in.getInt();
        if (sig != CENSIG) {
             throw new ZipException("Central Directory Entry not found");
        }

        in.position(8);
        int gpbf = in.getShort() & 0xffff;

        if ((gpbf & GPBF_UNSUPPORTED_MASK) != 0) {
            throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
        }

        int compressionMethod = in.getShort() & 0xffff;
        int time = in.getShort() & 0xffff;
        int modDate = in.getShort() & 0xffff;

        // These are 32-bit values in the file, but 64-bit fields in this object.
        long crc = ((long) in.getInt()) & 0xffffffffL;
        long compressedSize = ((long) in.getInt()) & 0xffffffffL;
        long size = ((long) in.getInt()) & 0xffffffffL;

        int nameLength = in.getShort() & 0xffff;
        int extraLength = in.getShort() & 0xffff;
        int commentByteCount = in.getShort() & 0xffff;

        // This is a 32-bit value in the file, but a 64-bit field in this object.
        in.position(42);
        long localHeaderRelOffset = ((long) in.getInt()) & 0xffffffffL;

        byte[] nameBytes = new byte[nameLength];
        in.get(nameBytes, 0, nameBytes.length);
        String name = new String(nameBytes, 0, nameBytes.length, UTF_8);

        ZipEntry entry = new ZipEntry(name);
        entry.setMethod(compressionMethod);
        entry.setTime(getTime(time, modDate));

        entry.setCrc(crc);
        entry.setCompressedSize(compressedSize);
        entry.setSize(size);

        // The RI has always assumed UTF-8. (If GPBF_UTF8_FLAG isn't set, the encoding is
        // actually IBM-437.)
        if (commentByteCount > 0) {
            byte[] commentBytes = new byte[commentByteCount];
            in.get(commentBytes, 0, commentByteCount);
            entry.setComment(new String(commentBytes, 0, commentBytes.length, UTF_8));
        }

        if (extraLength > 0) {
            byte[] extra = new byte[extraLength];
            in.get(extra, 0, extraLength);
            entry.setExtra(extra);
        }

        return entry;

    }
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:61,代碼來源:ZipEntryReader.java


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