List of usage examples for java.io Closeable close
public void close() throws IOException;
From source file:org.eclipse.ecr.common.utils.FileUtils.java
public static void safeClose(Closeable stream) { try {/*from ww w . j a va 2 s.c o m*/ stream.close(); } catch (IOException e) { // do nothing } }
From source file:com.android.callstat.common.net.MyHttpClient.java
/** * Close an {@linkplain Closeable} quietly. * /*from w w w. j a v a 2 s . co m*/ * @param closeable * the {@linkplain Closeable} to close. */ public static final void quietClose(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (final IOException e) { // Ignore errors. } } }
From source file:org.apache.jorphan.util.JOrphanUtils.java
/** * Close a Closeable with no error thrown * @param cl - Closeable (may be null)//from ww w. j ava 2 s. c o m */ public static void closeQuietly(Closeable cl) { try { if (cl != null) { cl.close(); } } catch (IOException ignored) { // NOOP } }
From source file:net.menthor.editor.v2.util.Util.java
/** * Attempt to close the file/stream/reader/writer and return true if and * only if we successfully closed it. (If object==null, we return true right away) *//*from w w w . j av a 2 s . c om*/ public static boolean close(Closeable object) { if (object == null) return true; boolean ans = true; try { if (object instanceof PrintStream && ((PrintStream) object).checkError()) ans = false; if (object instanceof PrintWriter && ((PrintWriter) object).checkError()) ans = false; object.close(); return ans; } catch (Throwable ex) { return false; } }
From source file:it.attocchi.jsf2.PageBase.java
private static void close(Closeable resource) { if (resource != null) { try {// w ww .j a va 2s .com resource.close(); } catch (IOException e) { // Do your thing with the exception. Print it, log it or mail // it. It may be useful to // know that this will generally only be thrown when the client // aborted the download. // e.printStackTrace(); logger.error("close", e); } } }
From source file:immf.Util.java
public static void safeclose(Closeable c) { if (c != null) { try {/*from w w w . j ava 2s . c om*/ c.close(); } catch (Exception e) { } } }
From source file:org.cru.godtools.api.notifications.Sender.java
private static void close(Closeable closeable) { if (closeable != null) { try {/* w ww . j a v a 2 s . c o m*/ closeable.close(); } catch (IOException e) { // ignore error log.info("IOException closing stream", e); } } }
From source file:org.zoumbox.mh_dla_notifier.MhDlaNotifierUtils.java
protected static void closeQuitely(Closeable closeable) { try {/*from ww w . ja va 2s .c o m*/ if (closeable != null) { closeable.close(); } } catch (IOException e) { Log.e(TAG, "Un exception occurred", e); } }
From source file:org.microg.gms.gcm.McsService.java
private static void tryClose(Closeable closeable) { if (closeable != null) { try {/*from w ww.ja va2 s . co m*/ closeable.close(); } catch (Exception ignored) { } } }
From source file:com.ibm.stocator.fs.common.Utils.java
/** * Close the Closeable objects and <b>ignore</b> any Exception or null * pointers. (This is the SLF4J equivalent of that in {@code IOUtils}). * * @param log the log to log at debug level. Can be null * @param closeables the objects to close */// www . j av a 2 s .com public static void closeAll(Logger log, java.io.Closeable... closeables) { for (java.io.Closeable c : closeables) { if (c != null) { try { if (log != null) { log.debug("Closing {}", c); } c.close(); } catch (Exception e) { if (log != null && log.isDebugEnabled()) { log.debug("Exception in closing {}", c, e); } } } } }