List of usage examples for java.io Closeable close
public void close() throws IOException;
From source file:au.org.ala.fielddata.mobile.service.WebServiceClient.java
protected void close(Closeable stream) { if (stream != null) { try {/*from ww w .ja v a2s .c o m*/ stream.close(); } catch (Exception e) { Log.e("WebServiceClient", "Error closing stream: ", e); } } }
From source file:br.com.semanticwot.cd.infra.LocalShell.java
private void secureClose(final Closeable resource) { try {// ww w.ja v a 2 s .c om if (resource != null) { resource.close(); } } catch (IOException ex) { log.log(Level.SEVERE, "Erro = {0}", ex.getMessage()); } }
From source file:org.interreg.docexplore.util.ZipUtils.java
public static void zip(File directory, File[] files, File zipfile, float[] progress, float progressOffset, float progressAmount, int level) throws Exception { URI base = directory.toURI(); Deque<File> queue = new LinkedList<File>(); OutputStream out = new FileOutputStream(zipfile, false); Closeable res = null; try {// w ww . ja va 2 s.c om int nEntries = count(files, queue, 0); while (!queue.isEmpty()) { File dir = queue.pop(); nEntries = count(dir.listFiles(), queue, nEntries); } ZipArchiveOutputStream zout = (ZipArchiveOutputStream) new ArchiveStreamFactory() .createArchiveOutputStream(ArchiveStreamFactory.ZIP, out); zout.setLevel(level); res = zout; int cnt = zip(files, queue, base, 0, nEntries, progress, progressOffset, progressAmount, zout); while (!queue.isEmpty()) { File dir = queue.pop(); cnt = zip(dir.listFiles(), queue, base, cnt, nEntries, progress, progressOffset, progressAmount, zout); } } finally { res.close(); } }
From source file:org.krakenapps.docxcod.FreeMarkerRunner.java
private void safeClose(Closeable o) { try {//from ww w . ja va 2 s. c om if (o != null) o.close(); } catch (IOException e) { // ignore } }
From source file:com.aoyetech.fee.commons.utils.IOUtils.java
public static void closeQuietly(final Closeable closeable) { try {/* w ww . j av a2s . c o m*/ if (closeable != null) { closeable.close(); } } catch (final IOException ioe) { // ignore } }
From source file:com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerAdapter.java
/** * Called when the Spring context is closed, this method stops reporters. *//*from ww w . j ava 2 s . co m*/ @Override public void destroy() throws Exception { if (this.reporters != null) { for (Closeable reporter : this.reporters) { try { reporter.close(); } catch (Exception ex) { LOG.warn("Problem stopping reporter", ex); } } } }
From source file:org.apache.hadoop.mapred.FileAllocationStore.java
private void close(Closeable closeable) { if (closeable != null) { try {/* ww w . j a v a2 s . co m*/ closeable.close(); } catch (Exception ce) { LOG.error("Error closing file: " + fileName, ce); } } }
From source file:com.intel.cryptostream.OpensslAesCtrCryptoCodec.java
@Override protected void finalize() throws Throwable { try {//from w w w . j a va 2s.co m Closeable r = (Closeable) this.random; r.close(); } catch (ClassCastException e) { } super.finalize(); }
From source file:gov.nih.nci.integration.validation.AESchematronValidatorTest.java
private void closeStream(Closeable s) { try {/*w ww . ja va2s . c om*/ if (s != null) { s.close(); } } catch (IOException e) { // do nothing } }
From source file:org.codehaus.mojo.native2ascii.Native2Ascii.java
private void closeQuietly(final File file, final Closeable closeable) { if (closeable != null) { try {/* ww w. ja va 2 s . c om*/ closeable.close(); } catch (final IOException e) { log.warn("Could not close the file: " + file.getAbsolutePath()); } } }