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 close(Closeable c) {
    if (c == null) {
        return;/*from ww  w . j  av a 2  s.  c  om*/
    }

    try {
        c.close();
    } catch (Exception e) {
    }
}

From source file:org.mates.osb.utils.FileUtils.java

/**
 * Close quietly closeable resource./*www  . j a va  2  s  .  c o m*/
 * 
 * @param what
 */
public static void closeQuietly(Closeable what) {
    if (what != null) {
        try {
            what.close();
        } catch (IOException e) {
            e.getMessage();
        }
    }
}

From source file:Main.java

public static void closeSilently(Closeable c) {
    if (c == null)
        return;/* w  w  w .  j av  a 2 s .c o  m*/
    try {
        c.close();
    } catch (Throwable t) {
        // do nothing
    }
}

From source file:Main.java

public static void close(Closeable... closeables) {
    if (closeables == null)
        return;//from w  w  w.  j  a v a 2 s .  c  o m
    for (Closeable c : closeables) {
        if (c == null)
            continue;

        try {
            c.close();
        } catch (Exception e) {
            Log.d("Closing", e.getMessage(), e);
        }
    }
}

From source file:Main.java

public static void closeAll(Closeable... closeables) {
    if (closeables.length <= 0)
        return;//from w  w w  . j a v a 2 s  .c  om

    for (Closeable closeable : closeables) {
        if (closeable == null)
            continue;
        try {
            closeable.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

public static void closeQuietly(Closeable closeable) {
    if (closeable != null) {
        try {/*  w w  w .  j  a v  a  2s  . c o  m*/
            closeable.close();
        } catch (Throwable ignored) {
        }
    }
}

From source file:com.amazonaws.util.IOUtils.java

/**
 * Closes the given Closeable quietly./*from  www.j av a2  s  .  com*/
 * @param is the given closeable
 * @param log logger used to log any failure should the close fail
 */
public static void closeQuietly(Closeable is, Log log) {
    if (is != null) {
        try {
            is.close();
        } catch (IOException ex) {
            if (log != null)
                log.debug("Ignore failure in closing the Closeable", ex);
        }
    }
}

From source file:podd.util.stream.StreamUtility.java

public static void closeStream(Closeable closable) throws IOException {
    if (null != closable) {
        closable.close();
    }//w w w.java 2  s .  c  o m
}

From source file:Main.java

public static void closeQuietly(Closeable... closeables) {
    if (closeables == null)
        return;/*  w  ww  .j  ava 2  s.  com*/
    for (Closeable closeable : closeables) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException e) {
                // http://stackoverflow.com/a/156525/9636
            }
        }
    }
}

From source file:Main.java

public static void closeQuietly(Closeable closeable) {
    if (closeable != null) {
        try {/*from ww w  . j a v a 2 s . c  o m*/
            closeable.close();
        } catch (RuntimeException rethrown) {
            throw rethrown;
        } catch (Exception ignored) {
        }
    }
}