package com.huawei.cn;
import java.io.*;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
public class compress {
public static void main(String[] args) throws Exception {
//输入流
BufferedReader bf=new BufferedReader(new InputStreamReader(new FileInputStream(args[0]),"GBK"));
//输出流
BufferedOutputStream out=new BufferedOutputStream(new DeflaterOutputStream(new FileOutputStream(args[1])));
System.out.println("this is starting compress");
int c=0;
while((c=bf.read())!=-1){
out.write(c);
}
bf.close();
out.close();
BufferedReader in2=new BufferedReader(
new InputStreamReader(
new InflaterInputStream(
new FileInputStream(args[1]))));
BufferedOutputStream out2=new BufferedOutputStream(new FileOutputStream(args[0]+"xixx"));
int d=0;
while((d=in2.read())!=-1){
out2.write(d);
}
out2.flush();
in2.close();
out2.close();
}
}
因为要验证deflate的算法,所以在java上跑一下,因为会跑到native库中。