Java Stream Close close(ZipFile file)

Here you can find the source of close(ZipFile file)

Description

Unconditionally close a ZipFile.

License

Apache License

Parameter

Parameter Description
file the <tt>ZipFile</tt>to close. May be <tt>null</tt> or already closed

Declaration

public static void close(ZipFile file) 

Method Source Code

//package com.java2s;
/*//from  ww  w . j av a  2s .  co  m
 * Copyright  2001-2005 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

import java.io.Closeable;

import java.io.IOException;

import java.util.zip.ZipFile;

public class Main {
    /**
     * Unconditionally close a <tt>Closable</tt>.
     * <p/>
     * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored.
     * This is typically used in finally blocks.
     *
     * @param closeable the <tt>Closable</tt>to close. May be <tt>null</tt> or already closed
     */
    public static void close(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException ignore) {
                // do nothing
            }
        }
    }

    /**
     * Unconditionally close a <tt>ZipFile</tt>.
     * <p/>
     * Equivalent to {@link ZipFile#close()}, except any exceptions will be ignored.
     * This is typically used in finally blocks.
     *
     * @param file the <tt>ZipFile</tt>to close. May be <tt>null</tt> or already closed
     */
    public static void close(ZipFile file) {
        if (file != null) {
            try {
                file.close();
            } catch (IOException ignore) {
                // do nothing
            }
        }
    }
}

Related

  1. close(RandomAccessFile randomAccessFile)
  2. close(Writer out)
  3. close(Writer stream)
  4. close(ZipFile file)
  5. close(ZipFile file)
  6. close(ZipFile zipFile)
  7. closeAll()
  8. closeAll()
  9. closeAll(Collection closeables)