public class test { public static void main(String[] args) {
String filePath = "d:/a.txt";
try {
GZIPOutputStream gos = new GZIPOutputStream(new FileOutputStream(
"d:/" + "aaaa.gz"));
InputStream in = new FileInputStream(filePath); System.out.println("To GZ start!");
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
gos.write(buf, 0, len);
}
System.out.println("To GZ end!"); in.close();
gos.finish();
gos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}GZIPOutputStream后缀