当前位置: 首页>>代码示例>>Java>>正文


Java ZipEntry.setComment方法代码示例

本文整理汇总了Java中java.util.zip.ZipEntry.setComment方法的典型用法代码示例。如果您正苦于以下问题:Java ZipEntry.setComment方法的具体用法?Java ZipEntry.setComment怎么用?Java ZipEntry.setComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.ZipEntry的用法示例。


在下文中一共展示了ZipEntry.setComment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: write

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private static void write(String name, String comment, String string, ZipOutputStream out) throws IOException {
	ZipEntry entry = new ZipEntry(name);
	entry.setComment(comment);
	out.putNextEntry(entry);

	PrintStream print = new PrintStream(out);
	print.println(string);
	print.flush();

	out.closeEntry();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:12,代码来源:BugReport.java

示例4: 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.setComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。