Here you can find the source of closeQuietly(Closeable stream)
Parameter | Description |
---|---|
stream | the object to close |
public static void closeQuietly(Closeable stream)
//package com.java2s; //License from project: Apache License import org.slf4j.LoggerFactory; import java.io.Closeable; public class Main { private static final org.slf4j.Logger logger = LoggerFactory.getLogger("intercom-java"); /**/* w w w. ja va 2s . c o m*/ * Close a stream, ignores checked Exceptions and nulls, * but rethrows RuntimeExceptions. * * @param stream the object to close */ public static void closeQuietly(Closeable stream) { if (stream != null) { try { stream.close(); } catch (RuntimeException rethrow) { throw rethrow; } catch (Exception e) { logger.warn(e.getMessage()); } } } }