Java Stream Close closeIgnoringException(final Closeable closeable)

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

Description

Closes java.io.Closeable instance ignoring IOException.

License

Open Source License

Parameter

Parameter Description
closeable to close

Declaration

public static void closeIgnoringException(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 {
    /**/*from w  w  w.  jav a  2  s. com*/
     * Closes {@link java.io.Closeable} instance ignoring IOException. Should be called from a finally block whenever {@link java.io.Closeable} is used.
     *
     * @param closeable
     *            to close
     */
    public static void closeIgnoringException(final Closeable closeable) {
        if (closeable == null)
            return;

        try {
            closeable.close();
        } catch (IOException ignored) {
            // We can do nothing if on close failure
        }
    }
}

Related

  1. closeGZipStream(GZIPOutputStream outStream)
  2. closeHTML(String pageTemplate, PrintStream out)
  3. closeIgnoreExceptions(Closeable c)
  4. closeIgnoreExceptions(Closeable stream)
  5. closeIgnoreIOEx(ByteArrayOutputStream baos)
  6. closeIgnoringExceptions(Closeable c)
  7. closeIgnoringExceptions(Closeable c)
  8. closeImage()
  9. closeIncludeGuard(String name, PrintWriter writer)