Java Stream Close closeWarnOnError(Closeable stream, Logger log, String message)

Here you can find the source of closeWarnOnError(Closeable stream, Logger log, String message)

Description

close Warn On Error

License

Open Source License

Declaration

static boolean closeWarnOnError(Closeable stream, Logger log, String message) 

Method Source Code

//package com.java2s;

import java.io.Closeable;

import java.io.IOException;

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

public class Main {
    static boolean closeWarnOnError(Closeable stream, Logger log, String message) {
        if (stream != null) {
            try {
                stream.close();/*  w w  w. j  av a 2 s  . c o  m*/
            } catch (IOException e) {
                if (message == null)
                    message = "Error while attempting to close";
                log.log(Level.WARNING, message + ": ", e);
                return false;
            }
        }
        return true;
    }

    static boolean closeWarnOnError(Closeable stream, Logger log) {
        return closeWarnOnError(stream, log, null);
    }
}

Related

  1. closeStreams(FileInputStream fis, FileOutputStream fos)
  2. closeStreams(InputStream iStream, OutputStream oStream)
  3. closeStreams(InputStream src, OutputStream dest)
  4. closeStreams(Process process)
  5. closeUnchecked(InputStream stream)
  6. closeWhileHandlingException(Closeable... objects)
  7. closeWithoutError(Object close)
  8. closeWithRuntimeException(Closeable c)
  9. closeWriteFile(FileOutputStream fileoutputstream)