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:se.vgregion.util.Util.java

/**
 * Close closables.//from   www .  ja  v a  2s .com
 *
 * @param closables the closables
 */
public static void closeClosables(Closeable... closables) {
    for (Closeable closeable : closables) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
}

From source file:azkaban.jobtype.connectors.teradata.TeraDataWalletInitializer.java

private static void close(Closeable closeable) throws IOException {
    if (closeable != null) {
        closeable.close();
    }// ww w .j a  va2  s  .  co  m
}

From source file:Main.java

/**
 * Closes the specified stream./*  w w w.j a va2 s. c o m*/
 * @param stream The stream to close.
 */
private static void closeStream(Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:de.xwic.appkit.core.remote.client.IoUtil.java

/**
 * @param closeMe/*  w  ww.j  a va  2  s  . c  o  m*/
 */
public static void close(final Closeable closeMe) {
    if (null == closeMe) {
        return;
    }
    try {
        closeMe.close();
    } catch (final IOException ex) {
        log.error("Failed to close resource", ex);
    }
}

From source file:com.varaneckas.hawkscope.util.IOUtils.java

/**
 * Closes a closeable without the annoying {@link IOException} or a 
 * null check//from   w ww. j a v  a2  s  . c  o  m
 * 
 * @param closeable
 */
public static void closeQuietly(final Closeable closeable) {
    try {
        if (closeable != null) {
            closeable.close();
        }
    } catch (final IOException e) {
        log.warn("Failed closing: " + closeable, e);
    }
}

From source file:com.intel.chimera.utils.IOUtils.java

/**
 * Closes the Closeable objects and <b>ignore</b> any {@link IOException} or
 * null pointers. Must only be used for cleanup in exception handlers.
 *
 * @param log the log to record problems to at debug level. Can be null.
 * @param closeables the objects to close.
 *///from  w  ww .  j  a v  a  2 s  .c o  m
public static void cleanup(Log log, java.io.Closeable... closeables) {
    for (java.io.Closeable c : closeables) {
        if (c != null) {
            try {
                c.close();
            } catch (Throwable e) {
                if (log != null && log.isDebugEnabled()) {
                    log.debug("Exception in closing " + c, e);
                }
            }
        }
    }
}

From source file:no.antares.clutil.hitman.MessageChannel.java

private static void close(Closeable s) {
    try {//w  ww  . java  2s.  c om
        if (s != null)
            s.close();
    } catch (IOException ioe) {
    }
}

From source file:Main.java

public static void closeIO(Closeable... closeables) {
    if (null == closeables || closeables.length <= 0) {
        return;/*from www . j a v  a 2  s. c  o m*/
    }
    for (Closeable cb : closeables) {
        try {
            if (null == cb) {
                continue;
            }
            cb.close();
        } catch (IOException e) {
            //   Logger.e(TAG, "close IO ERROR...", e);
        }
    }
}

From source file:org.brixcms.rmiserver.jackrabbit.RepositoryFactoryBean.java

public static final void close(Closeable c) {
    if (c != null) {
        try {/*from  w ww.j a v  a2  s. co m*/
            c.close();
        } catch (IOException e) {
            throw new RuntimeException("Could not close stream", e);
        }
    }
}

From source file:com.tomitribe.ee.TestArquillianHolyMoly.java

private static void close(final Closeable closeable) {
    try {//www .  j  av a2s  . c o m
        closeable.close();
    } catch (final IOException e) {
        //no-op
    }
}