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:Main.java

public static void closeSilently(@Nullable Closeable c) {
    if (c == null)
        return;/*from  w ww  . j  a va 2 s.co  m*/
    try {
        c.close();
    } catch (Throwable t) {
        // Do nothing
    }
}

From source file:com.ms.commons.utilities.StaticContentDeploy.java

private static void closeQuietly(Closeable... closeables) {
    for (Closeable closeable : closeables) {
        try {//from  w w w  .j a  v  a  2  s.  c om
            if (closeable != null) {
                closeable.close();
            }
        } catch (IOException e) {
            logger.error("close", e);
        }
    }
}

From source file:de.xwic.appkit.core.util.StreamUtil.java

/**
 * @param closable//from w w  w  .  j a  v  a 2s . c  o m
 * @param log
 */
public static void close(final Log log, final Closeable... closables) {
    for (final Closeable closable : closables) {
        if (null == closable) {
            continue;
        }
        try {
            closable.close();
        } catch (final IOException e) {
            log.error(e.getMessage(), e);
        }
    }
}

From source file:hudson.plugins.boundary.Boundary.java

private static void close(Closeable closeable) {
    if (closeable != null) {
        try {/* w  w w .  j a  va 2  s  .c o  m*/
            closeable.close();
        } catch (IOException e) {
            // Ignore
        }
    }
}

From source file:edu.mit.media.funf.util.IOUtil.java

/**
 * Closes a stream, and swallows null cases our IOExceptions.
 * @param stream/*from   ww w  . j  a  v a  2 s . co m*/
 */
public static boolean close(Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
            return true;
        } catch (IOException e) {
            Log.e(LogUtil.TAG, "Error closing stream", e);
        }
    }
    return false;
}

From source file:org.wso2.carbon.bpel.deployer.services.BPELUploader.java

public static void close(Closeable c) {
    if (c == null) {
        return;//from w  w  w  . j a v a2  s. com
    }
    try {
        c.close();
    } catch (IOException e) {
        log.warn("Can't close file streams.", e);
    }
}

From source file:com.lightboxtechnologies.io.IOUtils.java

/**
 * Close a {@link Closeable} unconditionally. Equivalent to
 * calling <code>c.close()</code> when <code>c</code> is nonnull.
 * {@link IOException}s are swallowed, as there is generally
 * nothing that can be done about exceptions on closing.
 *
 * @param c a (possibly <code>null</code>) <code>Closeable</code>
 *//*from www  .  j av  a2s . c o  m*/
public static void closeQuietly(Closeable c) {
    if (c == null)
        return;

    try {
        c.close();
    } catch (IOException e) {
        // ignore
    }
}

From source file:com.github.mjeanroy.springmvc.view.mustache.commons.IOUtils.java

/**
 * Close a {@link java.io.Closeable} object and do not throws a Checked Exception
 * if an exception occurs./*from w  w w  .j a  v a2 s. com*/
 *
 * @param stream Closeable stream.
 */
private static void closeQuietly(Closeable stream) {
    try {
        stream.close();
    } catch (IOException ex) {
        // Just log.
        log.debug(ex.getMessage(), ex);
    }
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.lucene.tools.LuceneHelperTools.java

/**
 * Close an object without throwing any error<br/>
 * log if any error occurs//from w w  w. ja v  a  2  s  .co m
 *
 * @param object
 */
public static void closeCloseableObjectQuietly(Closeable object) {
    try {
        if (object != null) {
            object.close();
            object = null;
        }
    } catch (IOException ioe) {
        logger.error("closeCloseableObjectQuietly failed", ioe);
    }
}

From source file:org.sonar.runner.api.Utils.java

static void closeQuietly(@Nullable Closeable c) {
    if (c == null) {
        return;//from  w w w .  j  a va  2 s.com
    }

    try {
        c.close();
    } catch (IOException e) {
        // ignore
    }
}