1.//建立gzip压缩文件输入流
2.建立gzip解压工作流
fileInputStream = new FileInputStream(filePath + fileName);
//解凍する
GZIPInputStream Zin = new GZIPInputStream(fileInputStream);
File outdir = new File(filePath);
this.extractFile(Zin, outdir, "1.txt");
将文件流进行输出到文件
private static void extractFile(GZIPInputStream in, File outdir, String name) throws IOException {
byte[] buffer = new byte[BUFFER_SIZE];
BufferedOutputStream out = new BufferedOutputStream(
new FileOutputStream(new File(outdir, name)));
int count = -1;
while ((count = in.read(buffer)) != -1) {
out.write(buffer, 0, count);
}
out.close();
}