View Javadoc

1   package net.sf.josceleton.commons.util;
2   
3   import java.io.Closeable;
4   import java.io.IOException;
5   
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   
9   /**
10   * @since 0.4
11   */
12  public final class CloseableUtil {
13  
14  	private static final Log LOG = LogFactory.getLog(CloseableUtil.class);
15  	
16  	private CloseableUtil() {
17  		// utility class is not instantiable
18  	}
19  	
20  	/**
21  	 * @since 0.4
22  	 */
23  	public static boolean close(final Closeable closeable) {
24          if (closeable == null) {
25              return false;
26          }
27          
28          try {
29  	        closeable.close();
30  	        return true;
31          } catch (final IOException e) {
32              LOG.warn("Could not close closeable [" + closeable.getClass().getSimpleName() + "]!", e);
33              return false;
34          }
35  	}
36  
37  }