Here you can find the source of closeQuietly(Closeable input, Logger log)
Parameter | Description |
---|---|
input | object to close |
log | external logger to use |
public static void closeQuietly(Closeable input, Logger log)
//package com.java2s; /**// w w w . j a va2 s.c om * Copyright 2013 MegaFon * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.slf4j.Logger; import java.io.Closeable; import java.io.IOException; public class Main { /** * Close I/O object quietly without exception * * @param input object to close */ public static void closeQuietly(Closeable input) { try { if (input != null) { input.close(); } } catch (IOException ioe) { // ignore, do nothing } } /** * Close I/O object quietly without exception but using external logger for logging errors if any * * @param input object to close * @param log external logger to use */ public static void closeQuietly(Closeable input, Logger log) { try { if (input != null) { input.close(); } } catch (IOException ioe) { log.warn("'close' invocation exception for resource: " + input.getClass().getName(), ioe); } } }