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(@Nullable Closeable c) {
    if (c == null)
        return;//from w ww.j a va2s.c om
    try {
        c.close();
    } catch (IOException ignored) {
    }
}

From source file:Main.java

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

From source file:Main.java

/**
 * Close the given closeable object (Stream) in a safe way: check if it is null and catch-log
 * exception thrown./*from   w  w  w .j a  v  a2 s. c  o  m*/
 *
 * @param closeable the closable object to close
 */
private static void closeSafe(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException ignored) {
        }
    }
}

From source file:Main.java

/**
 * Safely closes the given {@link Closeable} without throwing
 * any exceptions due to null pointers or {@link IOException}s.
 *
 * @param closeable The {@link Closeable} to close.
 *///  ww  w.  ja v a  2s  .  com
static void safeClose(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (IOException e) {
        }
    }
}

From source file:Main.java

public static void close(Closeable resource) {
    if (resource == null)
        return;//from w w  w. j av a2s .co m
    try {
        resource.close();
    } catch (IOException e) {
        // ignore
    }
}

From source file:Main.java

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

    }
}

From source file:Main.java

/**
 * Convenience function - closes the given stream (can be any Closable), catching and logging exceptions
 * @param stream a Closeable to close// ww  w.  java 2 s.com
 */
static public void close(final Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            Log.e("Vespucci", "Problem closing", e);
        }
    }
}

From source file:Main.java

public static void close(Closeable close) {
    try {/*from w  w w  . j a  va2s.c o  m*/
        if (close != null) {
            close.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void close(Closeable... closeables) throws IOException {
    if (closeables != null) {
        for (Closeable closeable : closeables) {
            if (closeable != null) {
                closeable.close();
            }/*from  ww  w .ja va 2s  . co m*/
        }
    }
}

From source file:Main.java

/**
 * Convenience function - closes the given stream (can be any Closable), catching and logging exceptions
 * @param stream a Closeable to close/*w  ww .  j  a  v a 2s .  c  o  m*/
 */
static public void close(final Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            Log.e("SavingHelper", "Problem closing", e);
        }
    }
}