首页 > 编程语言 > 详细

java 解压.gz文件

时间:2017-04-06 17:48:06      阅读:148      评论:0      收藏:0      [点我收藏+]

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();
      }

 

java 解压.gz文件

原文:http://www.cnblogs.com/sunxun/p/6674539.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!