Java Stream Close closeSilently(Object obj, Closeable stream)

Here you can find the source of closeSilently(Object obj, Closeable stream)

Description

close Silently

License

LGPL

Declaration

public static void closeSilently(Object obj, Closeable stream) 

Method Source Code


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

import java.io.Closeable;
import java.io.IOException;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static void closeSilently(Object obj, Closeable stream) {
        if (stream == null) {
            return;
        }/*from  w w  w. ja v  a2 s. c om*/
        try {
            stream.close();
        } catch (IOException e) {
            Logger.getLogger(obj.getClass().getName()).log(Level.WARNING, "Error occured while closing a stream.",
                    e);
        }
    }

    public static void closeSilently(Closeable stream) {
        if (stream == null) {
            return;
        }
        try {
            stream.close();
        } catch (IOException e) {
            Logger.getLogger("Utils").log(Level.WARNING, "Error occured while closing a stream.", e);
        }
    }
}

Related

  1. closeSilently(final InputStream is)
  2. closeSilently(InputStream in)
  3. closeSilently(InputStream inputStream)
  4. closeSilently(InputStream... inputStreams)
  5. closeSilently(java.util.logging.Logger log, Closeable stream)
  6. closeSilently(OutputStream outputStream)
  7. closeStatusFile(PrintWriter pwStatusFile)
  8. closeStream(Closeable aStream)
  9. closeStream(Closeable closeable)