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

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

From source file:Main.java

/**
 * Closes the specified stream./*w w w.  j av  a 2  s.c o m*/
 *
 * @param stream The stream to close.
 */
public static void closeStream(Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not close stream", e);
        }
    }
}

From source file:Main.java

public static void close(Closeable closeable) {
    try {/*from   w w w  . ja v  a2  s  .  com*/
        if (closeable != null) {
            closeable.close();
        }
    } catch (Throwable x) {
        // Ignored
    }
}

From source file:Main.java

public static void close(Closeable... closeables) {
    for (Closeable io : closeables) {
        if (io != null) {
            try {
                io.close();
            } catch (IOException e) {
                e.printStackTrace();//from ww  w.  java2  s  .  co m
            }
        }
    }
}

From source file:Main.java

public static void close(Closeable resource) {
    if (resource != null) {
        try {/*from  w  w  w. java2  s  .c  om*/
            resource.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

public static boolean safeClose(Closeable c) {
    boolean ret = false;
    if (c != null) {
        try {/*  w  ww  .  j a v a2 s .  c  om*/
            c.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return ret;
}

From source file:Main.java

public static final void close(Closeable closeable) {
    if (closeable != null) {
        try {/*from   www  .j  a v  a  2 s  . c  om*/
            closeable.close();
        } catch (IOException e) {

        }
    }
}

From source file:Main.java

public static void closeQuietly(Closeable closeable) {
    if (closeable == null)
        return;//from   w ww. j ava  2 s  . c o m
    try {
        closeable.close();
    } catch (IOException e) {
        //just ignore
    }
}

From source file:Main.java

public static void closeQuietly(Closeable closeable) {
    try {//from  ww  w . j a  va  2  s.  c o  m
        if (closeable != null) {
            closeable.close();
        }
    } catch (IOException ignore) {
    }
}

From source file:Main.java

public static void close(Closeable closeable) {
    try {// w w w  .ja  v  a 2  s.co  m
        if (closeable != null) {
            closeable.close();
        }
    } catch (Exception x) {
        // Ignored
    }
}