Java Stream Close closeStreamQuietly(final Closeable closeable)

Here you can find the source of closeStreamQuietly(final Closeable closeable)

Description

Close quietly an object which implements the Closeable interface such as InputStream, OutputStream, Reader ...

License

Open Source License

Parameter

Parameter Description
closeable - The stream to close, if <tt>null</tt> nothing is done.

Declaration

public static void closeStreamQuietly(final Closeable closeable) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.Closeable;

import java.io.IOException;

public class Main {
    /**/*w  w w  . ja  va2  s .  c  o  m*/
     * Close quietly an object which implements the {@link Closeable} interface
     * such as <tt>InputStream</tt>, <tt>OutputStream</tt>, <tt>Reader</tt> ...
     * 
     * @param closeable - The stream to close, if <tt>null</tt> nothing is done.
     * @see #closeAllStreamsQuietly(Closeable...)
     */
    public static void closeStreamQuietly(final Closeable closeable) {
        try {
            if (closeable != null)
                closeable.close();
        } catch (IOException ioe) {
            // Do nothing.
        }
    }
}

Related

  1. closeStream(InputStream inputStream)
  2. closeStream(InputStream ins)
  3. closeStream(Object oin)
  4. closeStream(OutputStream os)
  5. closeStreamIgnoreExpection(InputStream stream)
  6. closeStreams(FileInputStream fis, FileOutputStream fos)
  7. closeStreams(InputStream iStream, OutputStream oStream)
  8. closeStreams(InputStream src, OutputStream dest)
  9. closeStreams(Process process)