Java Stream Close closeIgnoringExceptions(Closeable c)

Here you can find the source of closeIgnoringExceptions(Closeable c)

Description

Provides an implementation of closing a file for use in a finally block so you can correctly close a file without even more exception handling stuff.

License

Open Source License

Parameter

Parameter Description
c The IO resource to close (e.g., a Stream/Reader)

Declaration

public static void closeIgnoringExceptions(Closeable c) 

Method Source Code

//package com.java2s;
import java.io.*;

public class Main {
    /**//from   www  .  j  a  va 2 s.c  om
     * Provides an implementation of closing a file for use in a finally block so
     * you can correctly close a file without even more exception handling stuff.
     * From a suggestion in a talk by Josh Bloch.
     *
     * @param c The IO resource to close (e.g., a Stream/Reader)
     */
    public static void closeIgnoringExceptions(Closeable c) {
        if (c != null) {
            try {
                c.close();
            } catch (IOException ioe) {
                // ignore
            }
        }
    }
}

Related

  1. closeIgnoreExceptions(Closeable c)
  2. closeIgnoreExceptions(Closeable stream)
  3. closeIgnoreIOEx(ByteArrayOutputStream baos)
  4. closeIgnoringException(final Closeable closeable)
  5. closeIgnoringExceptions(Closeable c)
  6. closeImage()
  7. closeIncludeGuard(String name, PrintWriter writer)
  8. closeInput(InputStream src)
  9. closeInputStream(DataInputStream di)