servlet在java中提取ZIP
各位
我正在提取数据。使用zip4jAPI在java中压缩文件,并能够提取文件
我曾经用zip压缩整个目录,使之成为zip,它包含文件和嵌套目录,使用
齐普菲尔。addFolder(文件目录,参数)//压缩目录文件/文件夹
使用
ZipFile zipFile = new ZipFile(stringArchievedFile); //Extracts all files to the path specified zipFile.extractAll(stringExtractingFilePath);
问题是在提取之后,应该将文件提取到我用zipFile.extractAll(path)
方法提供的路径,但是正在创建一个以上的目录。如何将文件解压缩到实际指定的目录
比如: 提取路径 C:\ExtractionPath
文件路径 C:\SelectingPath\File1
C:\SelectingPath\File2
C:\SelectingPath\Directory1\File1
C:\SelectingPath\Directory2\File1
我将选择C:\SelectingPath目录进行压缩并
我将选择C:\ExtractionPath目录来提取文件
提取后,所有提取的文件将进入
**C:\ExtractionPath\SelectingPath**
我需要目录中的所有文件
**C:\ExtractionPath** 本身
请帮我解决这个问题
提前谢谢
# 1 楼答案
你是否尝试过Zip4j site中的例子,比如:
# 2 楼答案
谢谢Andreas&;esprittn
我们需要将
ArrayList<File>
作为参数传递给addFiles(ArrayList, ZipParameters)
方法,以便归档目录的整个目录内容。我得到了预期的结果遵循存档代码流程:
而提取是