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 closeable) {
    if (null != closeable) {
        try {//from  www. j  ava 2  s .  co  m
            closeable.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

public static void close(Closeable closeable) {
    if (closeable != null) {
        try {/* w  w w. ja  va2  s  .c o m*/
            closeable.close();
        } catch (IOException var2) {
            var2.printStackTrace();
        }
    }
}

From source file:com.honnix.yaacs.util.StreamUtil.java

public static void closeStream(Closeable stream) {
    try {//from w w  w. ja  v  a 2  s.  c  om
        stream.close();
    } catch (IOException e) {
        LOG.warn("Error closing stream.", e);
    }
}

From source file:Main.java

/**
 * Closes properly objects implementing Closeable (input stream, output stream...)
 * //from w w  w. j  a  va  2s. c om
 * @param c
 *            object to close or null
 * @return IOException or null
 * 
 *         <p>
 *         <b>Be Careful:</b><br />
 *         In Android SDK 15 and earlier Cursor does not implement Closeable. So do not use with cursor.
 *         </p>
 */
public static IOException close(Closeable c) {
    if (c != null) {
        try {
            c.close();
        } catch (IOException e) {
            return e;
        }
    }
    return null;
}

From source file:Main.java

public static void closeIOQuietly(Closeable... closeables) {
    if (closeables == null)
        return;/*from  ww w  .  jav  a 2 s  . c om*/
    try {
        for (Closeable closeable : closeables) {
            if (closeable != null) {
                closeable.close();
            }
        }
    } catch (IOException e) {
        //            e.printStackTrace();
    }
}

From source file:Main.java

public static void closeIO(Closeable... closeables) {
    if (closeables == null)
        return;//from w  ww  .j a  v  a 2s . com
    try {
        for (Closeable closeable : closeables) {
            if (closeable != null) {
                closeable.close();
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void closeQuietly(Closeable closeable) {
    try {/*w  w w  .  j a v  a 2  s .  co  m*/
        if (closeable != null) {
            closeable.close();
        }
    } catch (IOException e) {
        // ignore
    }
}

From source file:org.lilyproject.util.io.IOUtils.java

public static void closeQuietly(Closeable cl) {
    if (cl != null) {
        try {//from  w w w  .jav a2 s.c o  m
            cl.close();
        } catch (Throwable t) {
            LogFactory.getLog(IOUtils.class).error("Problem closing a source or destination.", t);
        }
    }
}

From source file:Main.java

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

From source file:Main.java

public static void closeIO(Closeable[] closeables) {
    if ((closeables == null) || (closeables.length <= 0))
        return;/* ww  w.j  a  va  2 s .  c  om*/
    for (Closeable cb : closeables)
        try {
            if (cb != null) {
                cb.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
}