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:org.apache.nifi.file.FileUtils.java

/**
 * Closes the given closeable quietly - no logging, no exceptions...
 *
 * @param closeable/*from ww w  . j  a v  a2 s . c o m*/
 */
public static void closeQuietly(final Closeable closeable) {
    if (null != closeable) {
        try {
            closeable.close();
        } catch (final IOException io) {/*IGNORE*/

        }
    }
}

From source file:com.themodernway.server.core.io.IO.java

public static final void close(final Closeable c) {
    try {/*from  www.  j  a  va2s  .c o  m*/
        if (c != null) {
            c.close();
        }
    } catch (final IOException e) {
        if (logger.isDebugEnabled()) {
            logger.debug(LoggingOps.THE_MODERN_WAY_MARKER, "close()", e);
        }
    }
}

From source file:com.puppycrawl.tools.checkstyle.utils.CommonUtil.java

/**
 * Closes a stream re-throwing IOException as IllegalStateException.
 *
 * @param closeable/*from  ww w  . j  a  v a 2s  .co  m*/
 *            Closeable object
 */
public static void close(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException ex) {
            throw new IllegalStateException("Cannot close the stream", ex);
        }
    }
}

From source file:be.appfoundry.custom.google.android.gcm.server.Sender.java

private static void close(Closeable closeable) {
    if (closeable != null) {
        try {/*  ww  w  . j a  va  2  s.  co  m*/
            closeable.close();
        } catch (IOException e) {
            // ignore error
            logger.log(Level.FINEST, "IOException closing stream", e);
        }
    }
}

From source file:com.hazelcast.stabilizer.Utils.java

public static void closeQuietly(Closeable c) {
    if (c == null)
        return;//from w  ww  .j  a v  a 2  s  . c om
    try {
        c.close();
    } catch (IOException ignore) {
    }
}

From source file:com.taobao.android.builder.tools.zip.ZipUtils.java

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

From source file:org.limewire.util.FileUtils.java

/**
 * A utility method to close Closeable objects (Readers, Writers, 
 * Input- and OutputStreams and RandomAccessFiles).
 *///  ww  w  .  ja va 2s  . c  o  m
public static void close(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException ignored) {
        }
    }
}

From source file:org.eclipse.sw360.datahandler.common.CommonUtils.java

public static void closeQuietly(Closeable closeable, Logger logger) {
    if (closeable == null) {
        return;/*from w ww.j a  va 2  s .  co  m*/
    }
    try {
        closeable.close();
    } catch (IOException e) {
        logger.warn("cannot close closeable", e);
    }
}

From source file:marytts.util.io.FileUtils.java

/**
 * Close closeables. Use this in a finally clause.
 * @param Closeables closeables to close.
 *//*from  w w w .  j av a2  s  . co m*/
public static void close(Closeable... closeables) {
    for (Closeable c : closeables) {
        if (c != null) {
            try {
                c.close();
            } catch (Exception ex) {
                MaryUtils.getLogger(FileUtils.class.getName()).log(Level.WARN, "Couldn't close Closeable.", ex);
            }
        }
    }
}

From source file:bixo.fetcher.SimpleHttpFetcher.java

private static void safeClose(Closeable o) {
    if (o != null) {
        try {/*  w  ww.j  a v  a  2 s.  co  m*/
            o.close();
        } catch (Exception e) {
            // Ignore any errors
        }
    }
}