Java Stream Close closeIgnoreExceptions(Closeable c)

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

Description

Closes a data stream, ignoring any IOExceptions thrown

License

Open Source License

Parameter

Parameter Description
c some closeable stream (CSVWriter/Readers in this project)

Return

true if everything closed, false if IOException thrown

Declaration

public static boolean closeIgnoreExceptions(Closeable c) 

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 ww .ja v a2 s.c  o m
     * Closes a data stream, ignoring any IOExceptions thrown
     * @param c some closeable stream (CSVWriter/Readers in this project)
     * @return true if everything closed, false if IOException thrown
     */
    public static boolean closeIgnoreExceptions(Closeable c) {
        if (c != null) {
            try {
                c.close();
            } catch (IOException e) {
                e.printStackTrace();
                return false;
            }
        }
        return true;
    }
}

Related

  1. closeFiles(Closeable... closeables)
  2. closeFileWriter(BufferedWriter bw)
  3. closeFileWriter(FileWriter file)
  4. closeGZipStream(GZIPOutputStream outStream)
  5. closeHTML(String pageTemplate, PrintStream out)
  6. closeIgnoreExceptions(Closeable stream)
  7. closeIgnoreIOEx(ByteArrayOutputStream baos)
  8. closeIgnoringException(final Closeable closeable)
  9. closeIgnoringExceptions(Closeable c)