用java压缩文件示例(没有中文问题)
来源:岁月联盟
时间:2006-05-20
import java.io.*;
import java.util.zip.*;
/**
* @version Version 1.3
*/
public class w0514{
public static void main(String[] args){
try{
BufferedReader in=new BufferedReader(
new InputStreamReader(new FileInputStream(args[0]),"ISO8859_1"));
FileOutputStream f=new FileOutputStream(args[1]+".zip");
CheckedOutputStream ch=new CheckedOutputStream(f,new CRC32());
ZipOutputStream out=new ZipOutputStream(
new BufferedOutputStream(ch));
int c;
out.putNextEntry(new ZipEntry(args[0]));
while((c=in.read())!=-1)
out.write(c);
in.close();
out.close();
}
catch(Exception e){
e.printStackTrace();
}
}
} 编辑:xker.com
上一篇:返回列表
下一篇:Java性能优化技巧集锦(2)