用java压缩文件示例(没有中文问题)
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();
}
}
}
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论