Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

java解压zip文件为空-java解压各种类型的文件

我已经讲过怎样根据JAVA把JAR制成自缓解压力的exe文件。如今,要求收到了:当客户免费下载exe时,她们会全自动在exe文件中加上或遮盖某一文档。

思索:

java解压zip文件为空-java解压各种类型的文件插图1.自缓解压力exe文件由sfx,config.txt和7z压缩包构成。因而,没法同时开启SevenZFile。

2.从exe文件中,寻找config.txt末尾的部位.

3.将exe文件拆卸成2个临时文件夹:sfx config.txt文件和z7.7z压缩文件文档。

4.启用SevenZFile,再加上正中间的覆盖文件,产生一个新的压缩包,newz7.7z压缩文件。

5.将sfx config.txt文件和newz7.7z压缩文件合拼成exe初始解压缩文件。

编码如下所示:

在其中:d:\ test \ 7z self-extracting.exe是一个自缓解压力的exe文件。

/** * 查找文件中的config.txt末尾部位 * * @throws IOException */@Testpublic void getConfigEndPosTest() throws IOException {final File exeFile = new File("d:\test\7z自缓解压力.exe");final byte[] configEnd= ";!@InstallEnd@!".getBytes("ISO-8859-1");final BufferedInputStream exeBis = new BufferedInputStream(new FileInputStream(exeFile));// sfx假设超过124928exeBis.skip(124928);int b;long pos = 124928;int macth = 0;while ((b = exeBis.read()) != -1) {pos ;if (configEnd[macth] == b) {macth ;} else {macth = 0;}if (macth == 15) {System.out.print(pos);break;}}exeBis.close();}/** * 自压缩包拆分为: sfx config, 7z2个临时文件夹 * * @throws IOException */@Testpublic void splitFileTest() throws IOException {final File exeFile = new File("d:\test\7z自缓解压力.exe");final FileInputStream exeIn = new FileInputStream(exeFile);final File sfxFile = new File("d:\test\sfx.tmp");sfxFile.createNewFile();final FileOutputStream sfxOs = new FileOutputStream(sfxFile);// 125070 第一步求取的posbyte[] buffer = new byte[125070];int length;length = exeIn.read(buffer);sfxOs.write(buffer, 0, length);sfxOs.close();final File z7File = new File("d:\test\z7.7z");z7File.createNewFile();final FileOutputStream z7Os = new FileOutputStream(z7File);while ((length = exeIn.read(buffer)) > 0) {z7Os.write(buffer, 0, length);}z7Os.close();exeIn.close();}/** * 加上或遮盖的文档到7z * * @throws IOException */@Testpublic void writeFileTo7z() throws IOException { //略,7z文档解决}/** * sfx config 新的7z文档成exe. * @throws IOException */@Testpublic void mergeFile() throws IOException {//略, 参照前一篇的《JAVA JAR制作可自运行的EXE包》}

温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
未整理

雨婷《服装直播带货运营落地实操课》新号0粉快速带货日销10W+

2021-7-31 0:00:00

未整理

XnSay机器人授权系统源码

2021-8-2 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索