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


Java SevenZFile类代码示例

本文整理汇总了Java中org.apache.commons.compress.archivers.sevenz.SevenZFile的典型用法代码示例。如果您正苦于以下问题:Java SevenZFile类的具体用法?Java SevenZFile怎么用?Java SevenZFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SevenZFile类属于org.apache.commons.compress.archivers.sevenz包,在下文中一共展示了SevenZFile类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decompress

import org.apache.commons.compress.archivers.sevenz.SevenZFile; //导入依赖的package包/类
public static void decompress(File outputDirectory, File file, boolean outerworld, String type) {
    try {
        SevenZFile archive = new SevenZFile(file);
        SevenZArchiveEntry entry;
        while ((entry = archive.getNextEntry()) != null) {
            String filename = Paths.get(entry.getName()).getFileName().toString();

            if (tablesNeeded(outerworld, type).stream().anyMatch(filename::contains)) {
                log.info("Extracting {}", filename);
                byte[] content = new byte[(int) entry.getSize()];
                archive.read(content, 0, content.length);
                File outputFile = new File(outputDirectory, filename.replace(".gz", ""));
                try (GZIPInputStream input = new GZIPInputStream(new ByteArrayInputStream(content)); FileOutputStream output = new FileOutputStream(outputFile)) {
                    IOUtils.copy(input, output);
                }
            }
        }
        archive.close();
    }
    catch (IOException e) {
    throw propagate(e);
}
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:24,代码来源:ShapefileExtractor.java

示例2: parse

import org.apache.commons.compress.archivers.sevenz.SevenZFile; //导入依赖的package包/类
@Override
public void parse(File file) throws IOException {
    mEntries = new ArrayList<>();
    SevenZFile sevenZFile = new SevenZFile(file);

    SevenZArchiveEntry entry = sevenZFile.getNextEntry();
    while (entry != null) {
        if (entry.isDirectory()) {
            continue;
        }
        if (Utils.isImage(entry.getName())) {
            byte[] content = new byte[(int)entry.getSize()];
            sevenZFile.read(content);
            mEntries.add(new SevenZEntry(entry, content));
        }
        entry = sevenZFile.getNextEntry();
    }

    Collections.sort(mEntries, new NaturalOrderComparator() {
        @Override
        public String stringValue(Object o) {
            return ((SevenZEntry) o).entry.getName();
        }
    });
}
 
开发者ID:nkanaev,项目名称:bubble,代码行数:26,代码来源:SevenZParser.java

示例3: read

import org.apache.commons.compress.archivers.sevenz.SevenZFile; //导入依赖的package包/类
/**
 * Read from compressed file
 * 
 * @param srcPath
 *            path of compressed file
 * @param fileCompressor
 *            FileCompressor object
 * @throws Exception
 */
@Override
public void read(String srcPath, FileCompressor fileCompressor)
        throws Exception {
    long t1 = System.currentTimeMillis();
    byte[] data = FileUtil.convertFileToByte(srcPath);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SevenZFile sevenZFile = new SevenZFile(new File(srcPath));
    try {
        byte[] buffer = new byte[1024];
        int readByte;
        SevenZArchiveEntry entry = sevenZFile.getNextEntry();
        while (entry != null && entry.getSize() > 0) {
            long t2 = System.currentTimeMillis();
            baos = new ByteArrayOutputStream();
            readByte = sevenZFile.read(buffer);
            while (readByte != -1) {
                baos.write(buffer, 0, readByte);
                readByte = sevenZFile.read(buffer);
            }
            BinaryFile binaryFile = new BinaryFile(entry.getName(),
                    baos.toByteArray());
            fileCompressor.addBinaryFile(binaryFile);
            LogUtil.createAddFileLog(fileCompressor, binaryFile, t2,
                    System.currentTimeMillis());
            entry = sevenZFile.getNextEntry();
        }
    } catch (Exception e) {
        FileCompressor.LOGGER.error("Error on get compressor file", e);
    } finally {
        sevenZFile.close();
        baos.close();
    }
    LogUtil.createReadLog(fileCompressor, srcPath, data.length, t1,
            System.currentTimeMillis());
}
 
开发者ID:espringtran,项目名称:compressor4j,代码行数:45,代码来源:SevenZipProcessor.java

示例4: createArchiveInputStream

import org.apache.commons.compress.archivers.sevenz.SevenZFile; //导入依赖的package包/类
@Override
protected ArchiveInputStream createArchiveInputStream(File archive) throws IOException {
    return new SevenZInputStream(new SevenZFile(archive));
}
 
开发者ID:thrau,项目名称:jarchivelib,代码行数:5,代码来源:SevenZArchiver.java

示例5: SevenZInputStream

import org.apache.commons.compress.archivers.sevenz.SevenZFile; //导入依赖的package包/类
public SevenZInputStream(SevenZFile file) {
    this.file = file;
}
 
开发者ID:thrau,项目名称:jarchivelib,代码行数:4,代码来源:SevenZArchiver.java


注:本文中的org.apache.commons.compress.archivers.sevenz.SevenZFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。