List of usage examples for java.io Closeable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.ngdata.sep.util.io.Closer.java
/** * Closes anything {@link Closeable}, catches any throwable that might occur during closing and logs it as an error. *///w w w . j a v a 2 s .co m public static void close(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (Throwable t) { Log log = LogFactory.getLog(Closer.class); log.error("Error closing object of type " + closeable.getClass().getName(), t); } } }
From source file:ja.centre.util.io.Files.java
public static void closeQuietly(Closeable closable) { try {/*from w w w . ja v a2 s . com*/ close(closable); } catch (IOException e) { LOG.error("Could not close closable \"" + closable + "\" of class \"" + closable.getClass().getName() + "\"", e); } }
From source file:com.meltmedia.cadmium.servlets.guice.CadmiumListener.java
private void closeAll(Set<Class<? extends Closeable>> closed, Set<Object> singletons) { for (Object singleton : singletons) { if (singleton instanceof Closeable) { Closeable toClose = (Closeable) singleton; if (!closed.contains(toClose.getClass())) { closed.add(toClose.getClass()); log.info("Closing instance of {}", toClose.getClass().getName()); IOUtils.closeQuietly(toClose); }// w w w . j av a 2 s . c om } } }
From source file:org.apache.hadoop.hive.ql.exec.MapredContext.java
private boolean needClose(Closeable func) { try {// w ww . j a v a 2s . c o m Method closeMethod = func.getClass().getMethod("close"); return closeMethod.getDeclaringClass() != GenericUDF.class && closeMethod.getDeclaringClass() != GenericUDAFEvaluator.class; } catch (Exception e) { return false; } }
From source file:org.eclipse.skalli.core.search.LuceneIndex.java
private void closeQuietly(Closeable closable) { try {/* ww w . j a va2 s . com*/ if (closable != null) { closable.close(); } } catch (IOException e) { LOG.error(MessageFormat.format("Failed to close {0}", closable.getClass().getName()), e); } }
From source file:winterwell.jtwitter.URLConnectionHttpClient.java
/** * Close a reader/writer/stream, ignoring any exceptions that result. Also * flushes if there is a flush() method. * //w ww . j ava2s . com * @param input * Can be null */ protected static void close(Closeable input) { if (input == null) return; // Flush (annoying that this is not part of Closeable) try { Method m = input.getClass().getMethod("flush"); m.invoke(input); } catch (Exception e) { // Ignore } // Close try { input.close(); } catch (IOException e) { // Ignore } }