Java Stream Close closeSilently(java.util.logging.Logger log, Closeable stream)

Here you can find the source of closeSilently(java.util.logging.Logger log, Closeable stream)

Description

Closes the Closable and logs the exception if any

License

Open Source License

Parameter

Parameter Description
log a parameter
stream a parameter

Declaration

public final static void closeSilently(java.util.logging.Logger log, Closeable stream) 

Method Source Code

//package com.java2s;
/*/*from  ww w.  ja  va  2 s.  c o m*/
 * @(#)SequenceUtil.java 1.0 September 2009 Copyright (c) 2009 Peter Troshin
 * Jalview Web Services version: 2.0 This library is free software; you can
 * redistribute it and/or modify it under the terms of the Apache License
 * version 2 as published by the Apache Software Foundation This library is
 * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the Apache License for more details. A copy of the
 * license is in apache_license.txt. It is also available here: see:
 * http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or derived
 * work distributed in source code form must include this copyright and license
 * notice.
 */

import java.io.Closeable;

import java.io.IOException;

import java.util.logging.Level;

public class Main {
    /**
     * Closes the Closable and logs the exception if any
     * 
     * @param log
     * @param stream
     */
    public final static void closeSilently(java.util.logging.Logger log, Closeable stream) {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                log.log(Level.WARNING, e.getLocalizedMessage(), e.getCause());
            }
        }
    }
}

Related

  1. closeSecurityConfigurationFileInputStream(FileInputStream fis)
  2. closeSilently(final InputStream is)
  3. closeSilently(InputStream in)
  4. closeSilently(InputStream inputStream)
  5. closeSilently(InputStream... inputStreams)
  6. closeSilently(Object obj, Closeable stream)
  7. closeSilently(OutputStream outputStream)
  8. closeStatusFile(PrintWriter pwStatusFile)
  9. closeStream(Closeable aStream)