java怎么调用7zip进行压缩_JAVA使用7-zip解压缩带密码的Zip文件(非Proccess方法)...
首先到sourceforge网站下载sevenzipjbinding压缩包
我下载的版本是sevenzipjbinding-4.65-1.04-rc-extr-only-AllWindows.zip
publicvoidunzipDirWithPassword( final String sourceZipFile ,
final String destinationDir , final String password ){
RandomAccessFile randomAccessFile=null;
ISevenZipInArchive inArchive=null;try{
randomAccessFile=newRandomAccessFile(sourceZipFile,"r");
inArchive=SevenZip.openInArchive(null,//autodetect archive typenewRandomAccessFileInStream(randomAccessFile));//Getting simple interface of the archive inArchiveISimpleInArchive simpleInArchive=inArchive.getSimpleInterface();for(final ISimpleInArchiveItem item : simpleInArchive.getArchiveItems()){
finalint[] hash=newint[] {0};if(!item.isFolder()){
ExtractOperationResult result;
result=item.extractSlow(newISequentialOutStream(){publicintwrite(finalbyte[] data) throws SevenZipException{try{if(item.getPath().indexOf(File.separator)>0){
String path=destinationDir+File.separator+item.getPath(). substring(0,item.getPath().lastIndexOf(File.separator));
File folderExisting=newFile(path);if(!folderExisting.exists())newFile(path).mkdirs();
}if(!newFile(destinationDir+File.separator+item.getPath()).exists()){newFile(destinationDir).createNewFile();
}
OutputStreamout=newFileOutputStream(destinationDir+File.separator+item.getPath());out.write(data);out.close();
}catch( Exception e ){
e.printStackTrace();
}
hash[0]|=Arrays.hashCode(data);returndata.length;//Return amount of proceed data}
},password);///password.if(result==ExtractOperationResult.OK){
System.out.println(String.format("%9X | %s",
hash[0], item.getPath()));
}else{
System.err.println("Error extracting item:"+result);
}
}
}
}catch(Exception e){
e.printStackTrace();
}finally{if(inArchive!=null){try{
inArchive.close();
}catch(SevenZipException e){
System.err.println("Error closing archive:"+e);
e.printStackTrace();
}
}if(randomAccessFile!=null) {try{
randomAccessFile.close();
}catch(IOException e){
System.err.println("Error closing file:"+e);
e.printStackTrace();
}
}
}
java怎么调用7zip进行压缩_JAVA使用7-zip解压缩带密码的Zip文件(非Proccess方法)...相关推荐
- java压缩文件详解_Java解压和压缩带密码的zip文件过程详解
前言 JDK自带的ZIP操作接口(java.util.zip包,请参看文章末尾的博客链接)并不支持密码,甚至也不支持中文文件名. 为了解决ZIP压缩文件的密码问题,在网上搜索良久,终于找到了winzi ...
- java zip加密压缩_Java解压和压缩带密码的zip文件过程详解
前言 JDK自带的ZIP操作接口(java.util.zip包,请参看文章末尾的博客链接)并不支持密码,甚至也不支持中文文件名. 为了解决ZIP压缩文件的密码问题,在网上搜索良久,终于找到了winzi ...
- java zip 解压 密码_Java解压和压缩带密码的zip文件过程详解
前言 JDK自带的ZIP操作接口(java.util.zip包,请参看文章末尾的博客链接)并不支持密码,甚至也不支持中文文件名. 为了解决ZIP压缩文件的密码问题,在网上搜索良久,终于找到了winzi ...
- java 压缩解压密码zip_Java解压和压缩带密码的zip文件过程详解|chu
前言 JDK自带的ZIP操作接口(java.util.zip包,请参看文章末尾的博客链接)并不支持密码,甚至也不支持中文文件名. 为了解决ZIP压缩文件的密码问题,在网上搜索良久,终于找到了winzi ...
- java子类调用父类变量值_java子类如何调用父类变量和方法
深入浅出,保证一看就懂 package com.company; /** * Created by liuyazhou on 2016/9/21. */ public class Test { // ...
- java如何调用系统保存框_java使用poi实现excel导出之后如何弹出保存提示框
无论使用poi还是使用jxl导出excel都需要用到流 一种是outputstrean,另一种fileoutputstream 第一种:如果想要弹出保存的提示框必须加入下列三句 response.se ...
- java 使用7-zip解压缩带密码的压缩文件(非Proccess方法)
参考: http://lxw82307.iteye.com/blog/1009306 所需要的包: 适用于所有平台(经测试并未对移动设备平台支持) sevenzipjbinding-4.65-1.04 ...
- java中完成md5加密解密_java实现md5加密解密 notNET中加密和解密的实现方法
java实现md5加密解密 notNET中加密和解密的实现方法 亦或是旅途风光 7-14 1918℃ 22 [ ee21.cn - ASP.NET ] .NET将原来独立的API和SDK合并到一个框架 ...
- Java实现自定义队列和树结构_Java数据结构之链表、栈、队列、树的实现方法示例...
本文实例讲述了java数据结构之链表.栈.队列.树的实现方法.分享给大家供大家参考,具体如下: 最近无意中翻到一本书,闲来无事写几行代码,实现几种常用的数据结构,以备后查. 一.线性表(链表) 1.节 ...
最新文章
- python turtle怎么用变量_Python Turtle绘图指定变量时出现问题
- 玩转webpack(一)下篇:webpack的基本架构和构建流程
- keras从入门到放弃(十四)模型的保存
- collection配置说明
- HDU 6706 huntian oy
- linux 下脚本查看带宽 (不需要安装其他工具包)
- 服务器如何启动运行,如何在服务器系统启动或重新启动时执行命令或脚本
- java随机安排座位表程序_java – 为长凳生成随机座位表的最有效算法?
- 嵌入式(二)——Jlink接口定义
- 网络游戏植入游戏案例
- Python 内置容器 之 字典 ( dict )超详细指南
- android 如何绕过签名校验
- win10怎么更新显卡驱动_Intel发布核显新驱动:支持Win10 H2更新、11代酷睿狂喜-Intel,核显,驱动,Win10 ——快科技(驱动之家旗下媒体)-...
- 好系统教你Win7系统开机启动慢怎么解决?
- 10个方法教你解决虚幻4运行崩溃问题
- Adobe软件试用下载
- flashback的配置
- 网站被劫持到其它网站如何解决
- 读了两年“游戏学院”才知被忽悠
- 店宝宝软件用数据说明:新手电商创业需知这四点
热门文章
- [摸鱼]cdq分治 学习笔记
- LeetCode | HouseCode 算法题
- mysql root用户密码个性
- 【翻译】在Ext JS中创建特定主题的重写
- 关于如何在BCB中使用CodeGuard
- redis事务的简单介绍
- dynmic_debug动态控制kernel下的日志输出
- java创建一个未知长度的数组_Java数组的创建操作
- ValueError: check_hostname requires server_hostname的解决办法
- mysql整数索引没用到_MYSQL 索引无效和索引有效的详细介绍