集册 Java实例教程 是按其内容显示的Gzip文件

是按其内容显示的Gzip文件

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

360
是按其内容显示的Gzip文件


//package com.nowjava;
/* from 
时 代 J     a    v  a - nowjava.com*/


import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;


import java.util.zip.GZIPInputStream;


public class Main {

    public static void main(String[] argv) throws Exception {

        File f = new File("Main.java");

        System.out.println(isGzip(f));

    }


    public static boolean isGzip(final File f) throws IOException {

        FileInputStream fis;

        boolean returnValue = false;
        /*
        来 自*
         时代Java公众号
        */


        fis = new FileInputStream(f);

        try {

            new GZIPInputStream(fis);

            returnValue = true;

        } catch (final IOException io) {

            // If we got here the file is readable but not in GZIP format

            
展开阅读全文