Example usage for java.io Closeable close

List of usage examples for java.io Closeable close

Introduction

In this page you can find the example usage for java.io Closeable close.

Prototype

public void close() throws IOException;

Source Link

Document

Closes this stream and releases any system resources associated with it.

Usage

From source file:foam.littlej.android.app.net.MainHttpClient.java

/**
 * Closes the specified stream./* w  ww  . jav  a  2s .  c  om*/
 * 
 * @param stream
 *            The stream to close.
 */
private void closeStream(Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            android.util.Log.e("IO", "Could not close stream", e);
        }
    }
}

From source file:org.cloudgraph.hbase.mapreduce.GraphInputFormat.java

private void close(Closeable... closables) throws IOException {
    for (Closeable c : closables) {
        if (c != null) {
            c.close();
        }// ww w.ja v  a2s  . c o m
    }
}

From source file:org.apache.atlas.repository.audit.HBaseBasedAuditRepository.java

private void close(Closeable closeable) throws AtlasException {
    if (closeable != null) {
        try {/* w ww  .  j a v  a2s .  co m*/
            closeable.close();
        } catch (IOException e) {
            throw new AtlasException(e);
        }
    }
}

From source file:org.rhq.modules.plugins.wildfly10.ASUploadConnection.java

private void closeQuietly(final Closeable closeable) {
    if (closeable != null) {
        try {/*www .  j a  v  a 2  s  . c  om*/
            closeable.close();
        } catch (final IOException ignore) {
        }
    }
}

From source file:NanoHTTPD.java

private static final void safeClose(Closeable closeable) {
    if (closeable != null) {
        try {/* w w  w  .  ja va  2s  .c om*/
            closeable.close();
        } catch (IOException e) {
        }
    }
}

From source file:cn.knet.showcase.demos.servletproxy.ProxyServlet.java

protected void closeQuietly(Closeable closeable) {
    try {/* w ww.j  a  v  a2 s .  co m*/
        closeable.close();
    } catch (IOException e) {
    }
}

From source file:org.apache.kylin.common.metrics.metrics2.CodahaleMetrics.java

@Override
public void close() throws Exception {
    if (reporters != null) {
        for (Closeable reporter : reporters) {
            reporter.close();
        }//from   ww  w.  j  a  v  a2  s.co m
    }
    for (Map.Entry<String, Metric> metric : metricRegistry.getMetrics().entrySet()) {
        metricRegistry.remove(metric.getKey());
    }
    timers.invalidateAll();
    counters.invalidateAll();
    meters.invalidateAll();
}

From source file:org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsInProc.java

/** {@inheritDoc} */
@Override/*from  www  .ja v a  2 s.  c  om*/
public void closeStream(HadoopIgfsStreamDelegate desc) throws IOException {
    Closeable closeable = desc.target();

    try {
        closeable.close();
    } catch (IllegalStateException e) {
        throw new IOException("Failed to close IGFS stream because Grid is stopping.", e);
    }
}

From source file:org.apache.solr.util.TestSolrCLIRunExample.java

@After
public void tearDown() throws Exception {
    super.tearDown();

    if (closeables != null) {
        for (Closeable toClose : closeables) {
            try {
                toClose.close();
            } catch (Exception ignore) {
            }/*w  w  w.  j ava  2  s . co m*/
        }
        closeables.clear();
        closeables = null;
    }
}