package impl; import inter.AbstractUnCompressService; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry; import org.apache.commons.compress.archivers.sevenz.SevenZFile; /** * This file is used to uncompress 7z file * * @author Jacky.Dong * */ public class SevenZUnCompressServiceImpl extends AbstractUnCompressService { private static final String SUFFIX_SEVENZ = ".7z"; @Override public void unCompressFolder(String folder) { // TODO Auto-generated method stub } @Override public void unCompressFile(String inputFilePath, String outputDir) throws IOException { File inputFile = new File(inputFilePath); // if output directory is not specify,we will use input file parent path // + // compress file name as output file path if (outputDir == null) { outputDir = inputFile.getPath().replace(SUFFIX_SEVENZ, "") + File.separator; } try { // create 7z input stream SevenZFile zFile = new SevenZFile(inputFile); SevenZArchiveEntry entry = null; while ((entry = zFile.getNextEntry()) != null) { // once entry is a directory we will create a new directory if (entry.isDirectory()) { createDirectory(outputDir, entry.getName()); } else { File tmpFile = new File(outputDir + File.separator + entry.getName()); createDirectory(tmpFile.getParent() + File.separator, null); OutputStream out = null; try { out = new FileOutputStream(tmpFile); int length = 0; byte[] b = new byte[BUFFEREDSIZE]; while ((length = zFile.read(b)) != -1) { out.write(b, 0, length); } } catch (IOException ex) { throw ex; } finally { if (out != null) out.close(); } } } } catch (Exception ex) { System.err.println(ex.toString()); } } }
相关推荐
java 解析 json文件java 解析 json文件java 解析 json文件java 解析 json文件java 解析 json文件
解析msg的java类库msgparser-1.12.zip
基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化...
基于java的开发源码-用GZIP压缩解压文件.zip 基于java的开发源码-用GZIP压缩解压文件.zip 基于java的开发源码-用GZIP压缩解压文件.zip 基于java的开发源码-用GZIP压缩解压文件.zip 基于java的开发源码-用GZIP压缩...
用JAVA解析DBC文件,考虑大小端,生成文件内容跟Vector CANDB++相同。
java解析PDF格式的文件demo。JAVA实现PDF解析,对PDF文件中的文本内容可输出仅供参考学习,不喜勿喷。
java解析XML文件java解析XML文件java解析XML文件java解析XML文件java解析XML文件java解析XML文件
MeteoInfo-Java解析与绘图教程(八)_java解析卫星FY-4A一级产品文件(HDF举例).doc
java使用superMap解析DWG文件为json输出,本地通过,附件中为word操方式按照步骤可以导入数据集
基于java的开发源码-用Zip压缩多个文件实例源码.zip 基于java的开发源码-用Zip压缩多个文件实例源码.zip 基于java的开发源码-用Zip压缩多个文件实例源码.zip 基于java的开发源码-用Zip压缩多个文件实例源码.zip 基于...
基于Batik的对svg文件进行解析显示
java使用geotools解析shp文件,内容包含 解析方法,使用的各种jar包,以及单区域shp和多区域shp文件
java对mht文件解析,并实现内容的抓取
java 解析 chm 文件 生成 html 解析 chm 文件
首先完整的内容应该是实现java解析wsdl文档获取方法与参数,然后使用soapui发送soap请求获取返回值并解析,而且基本可以解析主流webservice框架生成的wsdl
Java - jdk1.8 - 压缩文件
Java解析CSV文件
Java压缩及解压tar、tar.z格式文件, 需要apache的包ant-1.7.1.jar 这个自己去搜索下下载
在这个实战博客中,我们将创建一个简单的Java文件压缩工具,用于创建和解压缩文件归档。我们将深入了解Java编程语言以及Java的压缩和解压缩库,以帮助您构建自己的文件压缩工具。 以下是本实战博客的主要内容: ...
java解析dbf文件方案.pdf