java.util.zip.ZipOutputStream压缩无乱码(原创)
package io; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.zip.Adler32; import java.util.zip.CheckedOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class ZipCompress { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub String[] fileNames={"config.properties","中文.properties","中文.csv"}; FileOutputStream f=new FileOutputStream("test.zip"); CheckedOutputStream csum=new CheckedOutputStream(f, new Adler32()); ZipOutputStream zos=new ZipOutputStream(csum); BufferedOutputStream out=new BufferedOutputStream(zos); zos.setComment("comment"); for (String fileName : fileNames) { BufferedReader in=new BufferedReader(new InputStreamReader(new FileInputStream(fileName),"GBK")); zos.putNextEntry(new ZipEntry(fileName)); String temp; while((temp=in.readLine())!=null){ out.write(temp.getBytes("GBK")); } in.close(); out.flush(); } out.close(); } }