集册 Java实例教程 从经过gzip压缩的文件中获取InputStream。

从经过gzip压缩的文件中获取InputStream。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

481
从经过gzip压缩的文件中获取InputStream。
/**NowJava.com**/


//package com.nowjava;

import java.io.*;

import java.util.zip.GZIPInputStream;


public class Main {

    /**

     * gets an InputStream from a file that is gzip compressed.

     *

     * @param file

     * @return

     * @throws IOException

     */

    public static InputStream getCompressedFileAsStream(final File file)

            throws IOException {

        return new GZIPInputStream(new BufferedInputStream(

                new FileInputStream(file)));

    }

}