Java Stream Close closeQuietly(InputStream is)

Here you can find the source of closeQuietly(InputStream is)

Description

Closes the given input stream without throwing an exception.

License

Apache License

Parameter

Parameter Description
is the input stream to be closed, may be <b>null</b>

Declaration

public static void closeQuietly(InputStream is) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import java.util.jar.JarFile;

public class Main {
    /**/*from  ww w .j  ava 2  s .com*/
     * Closes the given JAR file without throwing an exception.
     * 
     * @param file the JAR file to be closed, may be <b>null</b>
     */
    public static void closeQuietly(JarFile file) {
        if (null != file) {
            try {
                file.close();
            } catch (IOException e) {
            }
        }
    }

    /**
     * Closes the given input stream without throwing an exception.
     * 
     * @param is the input stream to be closed, may be <b>null</b>
     */
    public static void closeQuietly(InputStream is) {
        if (null != is) {
            try {
                is.close();
            } catch (IOException e) {
            }
        }
    }

    /**
     * Closes the given output stream without throwing an exception.
     * 
     * @param os the output stream to be closed, may be <b>null</b>
     */
    public static void closeQuietly(OutputStream os) {
        if (null != os) {
            try {
                os.close();
            } catch (IOException e) {
            }
        }
    }
}

Related

  1. closeQuietly(InputStream is)
  2. closeQuietly(InputStream is)
  3. closeQuietly(InputStream is)
  4. closeQuietly(InputStream is)
  5. closeQuietly(InputStream is)
  6. closeQuietly(InputStream stream)
  7. closeQuietly(InputStream x)
  8. closeQuietly(java.io.Closeable writer)
  9. closeQuietly(Object input)