android 解压.Z后缀的压缩包

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/oqzuser1q2w3e4r5t/article/details/74549803

http://www.oschina.net/news/48067/apache-commons-compress-1-7

这是查到的资料



最近接受了一个新任务中,有一项功能要处理.Z后缀的压缩包   上网搜索一段时间。 Commons Compress 1.7 这个开源是可以满足解压.Z后缀的压缩包的,而且它还支持解压多种格式的压缩包。

  private static File upZipFile(File file) {  

FileOutputStream out = null;  

ZCompressorInputStream zIn = null;  

try { FileInputStream fin = new FileInputStream(file);  

BufferedInputStream in = new BufferedInputStream(fin);  

String name = file.getName().substring(0, file.getName().indexOf("."));  

File outFile = new File("/mnt/sdcard/" + name.substring(0,4));  

fos = new FileOutputStream(outFile);  

zcis = new ZCompressorInputStream(in);  

final byte[] buffer = new byte[2048];  

int n = 0;  

while (-1 != (n = zIn.read(buffer))) {  

fos.write(buffer, 0, n);  

}  

success = true;  

return outFile;  

} catch (Exception e) {  

e.printStackTrace();  

return null; } finally {  

try {  

fos.close();  

zcis.close();  

} catch (IOException e) {  

e.printStackTrace();  

} } }

先后导入了commons-compress-1.7.jar和commons-compress-1.10.jar试验都可以成功完成解压



猜你喜欢

转载自blog.csdn.net/oqzuser1q2w3e4r5t/article/details/74549803
今日推荐