阿帕奇解压测试7z

相关文件:

1、测试程序上传

将目录 阿帕奇解压测试Zip\程序 下的text_7z 文件夹上传服务器/root目录下。

2、测试程序运行

进入程序所在目录

1
cd /root/test_7z/src/zip_7/

通过javac将.java编译为.class文件;

其编译命令如下:

1
javac -classpath "/root/test_7z/lib/*" Test7z.java

通过Java执行.class文件

1
java -cp $classpath:"/root/test_7z/lib/*":./ Test7z

正确现象

终端:无输出

在文件目录中

目录:/root/test_7z/src/zip_7/ 下将会多出一个名为my-test-archive的文件夹,其中有6个文件,如下图所示:

3、总结

请详细记录相关信息,测试结束后做出反馈。

程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class Test7z {
public static void main(String[] args) {
try {
SevenZFile zipFile = new SevenZFile(new File("/root/test_7z/src/zip_7/my-test-archive.7z"));
byte[] buffer = new byte[4096];
Iterable<SevenZArchiveEntry> entries = zipFile.getEntries();
InputStream inputStream;
for (SevenZArchiveEntry entry : entries) {
if (entry.isDirectory()) {
continue;
}

File outputFile = new File("/root/test_7z/src/zip_7/" + entry.getName());

if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}

try {
inputStream = zipFile.getInputStream(entry);
FileOutputStream fos = new FileOutputStream(outputFile);
while (inputStream.read(buffer) > 0) {
fos.write(buffer);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}

阿帕奇解压测试7z
http://yuanql.top/2022/11/13/00_项目经历/信创项目/专用系统下压缩软件验证/阿帕奇解压测试7z/
作者
Qingli Yuan
发布于
2022年11月13日
许可协议