java 解压.gz文件


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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM