public class GzipPcompress {
public static void main(String args[]) {
GzipPcompress gzip = new GzipPcompress() ;
String sourcePathAndName = "F:/download/20150819.txt" ;
String pressPathAndName = "F:/download/a.gz" ;
gzip.gzPressFile(sourcePathAndName, pressPathAndName);
}
public void gzPressFile(String sourcePathAndName ,String pressPathAndName ){
try {
BufferedReader in = new BufferedReader(new FileReader(sourcePathAndName));
BufferedOutputStream out = new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(pressPathAndName)));
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
in.close();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
java 压缩.gz
最新推荐文章于 2024-04-08 22:20:42 发布