集册 Java实例教程 是Zip文件的内容

是Zip文件的内容

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

445
是Zip文件的内容
/*nowjava - 时代Java 提供*/


//package com.nowjava;

import java.io.BufferedInputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.util.zip.CRC32;

import java.util.zip.CheckedInputStream;


import java.util.zip.ZipEntry;

import java.util.zip.ZipInputStream;


public class Main {

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

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

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

    }


    public static boolean isZip(final File f) throws IOException {// 来自 n o w j a   v  a . c o m - 时  代  Java

        // String absoluteName = f.getAbsolutePath();

        FileInputStream fis = null;

        boolean returnValue = false;

        try {

            fis = new FileInputStream(f);

            final CheckedInputStream cis = new CheckedInputStream(fis,

                    new CRC32());

            final ZipInputStream zis = new ZipInputStream(

                    new BufferedInputStream(cis));

            final ZipEntry ze = zis.getNextEntry();

展开阅读全文