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.reactor.monitoring.util.FileHandler.java

public static void close(Closeable closer) {
    try {/*from   w  w  w . ja  v  a2s  . c  o m*/
        closer.close();
    } catch (Exception ex) {

    }
}

From source file:blast.shell.karaf.ssh.BlastShellFactoryImpl.java

private static void close(Closeable... closeables) {
    for (Closeable c : closeables) {
        try {//from   ww  w  . j a v a2 s .co  m
            c.close();
        } catch (IOException e) {
            // Ignore
        }
    }
}

From source file:com.googlecode.xmlzen.utils.FileUtils.java

/**
 * Closes a {@link Closeable}, for instance a {@link FileInputStream}.
 * <p>/*from  w w w .  j  av  a  2 s.  c  o  m*/
 * Null-safe, Supresses the IOException.</p>
 * 
 * @param closeable A {@link Closeable} object to be closed
 */
public static void close(final Closeable closeable) {
    if (closeable == null) {
        return;
    }
    try {
        closeable.close();
    } catch (final IOException e) {
        log.debug("Failed closing " + closeable + ". Ignoring exception.");
    }
}

From source file:org.apache.tajo.util.FileUtil.java

/**
 * Close the Closeable objects and <b>throw</b> first {@link IOException}, if failed
 * @param closeables the objects to close
 *///from  www.j av  a 2 s.c  o  m
public static void cleanupAndthrowIfFailed(java.io.Closeable... closeables) throws IOException {
    IOException ioe = null;

    for (java.io.Closeable c : closeables) {
        if (c != null) {
            try {
                c.close();
            } catch (IOException e) {
                if (ioe == null)
                    ioe = e;
            }
        }
    }

    if (ioe != null) {
        throw ioe;
    }
}

From source file:org.nuxeo.client.api.marshaller.NuxeoResponseConverterFactory.java

static void closeQuietly(Closeable closeable) {
    if (closeable == null)
        return;//from  w ww  . j  av a2  s .  com
    try {
        closeable.close();
    } catch (IOException ignored) {
    }
}

From source file:com.foglyn.fogbugz.Utils.java

/**
 * Closes stream and ignores error while doing so. Don't use with output streams!
 * @param stream/*from   w  w w  .j a v  a2 s  .  c  om*/
 */
static void close(Closeable stream) {
    if (stream == null) {
        return;
    }

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

From source file:org.smartfrog.services.hadoop.benchmark.citerank.CiteRankTool.java

protected static void close(Closeable c) throws IOException {
    if (c != null) {
        c.close();
    }/*from  w w w .  j  av a 2s  . com*/
}

From source file:org.apache.any23.util.StreamUtils.java

/**
 * Closes the closable interface and reports error if any.
 *
 * @param closable the closable object to be closed.
 *///w ww  .  ja v  a  2  s.  c  o m
public static void closeGracefully(Closeable closable) {
    if (closable != null) {
        try {
            closable.close();
        } catch (Exception e) {
            logger.error("Error while closing object " + closable, e);
        }
    }
}

From source file:edu.umd.cs.buildServer.util.IO.java

public static void closeSilently(Closeable... args) {
    for (Closeable c : args)
        if (c != null)
            try {
                c.close();
            } catch (IOException e) {
                // ignore
            }//  w  w  w  .ja v  a 2s . c  o  m
}

From source file:volker.streaming.music.lastfm.LastFmApi.java

private static void close(Closeable... cs) {
    for (Closeable c : cs) {
        try {/*from w w w.ja v  a2 s  .c o  m*/
            if (c != null)
                c.close();
        } catch (IOException e) {
            LOG.error("Failed to properly close something.", e);
        }
    }
}