Java版的WinRAR工具

欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入

测试代码:

public class Test { public static void main(String[] args) throws IOException { Collection<File> resFileList = new ArrayList<File>(); resFileList.add(new File(“C:\\new.gif”)); resFileList.add(new File(“C:\\HelloWorld.java”)); resFileList.add(new File(“C:\\crebas.sql”)); resFileList.add(new File(“E:\\log.log”)); resFileList.add(new File(“C:\\ooo\\upx\\”)); File zipFile = new File(“C:\\txxxt.zip”); ZipUtils.zipFiles(resFileList, zipFile); } }

运行结果:

压缩成功!
Process finished with exit code 0

查看硬盘的上压缩文件,没错,贴个图看看:

呵呵,经过查看,没问题,就是注释乱码。

经过反复测试,发现中文支持有问题。

google了一下解决方案,用ant包中的两个类

//import org.apache.tools.zip.ZipEntry;

//import org.apache.tools.zip.ZipOutputStream;

替换Java包的对应的两个类

import java.util.zip.ZipFile;

import java.util.zip.ZipOutputStream;

即可完美支持中文。

[1][2]

筑起梦想的鸟巢,开始人生的长跑,领先每回的冲刺,

Java版的WinRAR工具

相关文章:

你感兴趣的文章:

标签云: