编码,java,utf-8,gbk 博客分类: Java&Eclipse JavaF#
程序员文章站
2024-02-04 23:31:28
...
try { ZipOutputStream out = new ZipOutputStream(new FileOutputStream(fileName)); out.setEncoding("UTF-8"); for (File f:files) { String name = f.getName(); if(f instanceof CustomFile){ CustomFile cf = (CustomFile) f; name = cf.getTitleName(); }
out.setEncoding("UTF-8");
做文件压缩时,注意红色这行,由于文件名是从数据库utf-8编码读出来的,解压文件发现乱码,只要设置这行就行了,走了很多弯路啊!!!