Java Utililty Methods Stream Close

List of utility methods to do Stream Close

Description

The list of methods to do Stream Close are organized into topic(s).

Method

voidcloseIgnoreExceptions(Closeable stream)
Closes the given stream and ignores all IOExceptions thrown by the close operation.
if (stream == null)
    return;
try {
    stream.close();
} catch (InterruptedIOException e) {
    Thread.currentThread().interrupt();
} catch (IOException e) {
voidcloseIgnoreIOEx(ByteArrayOutputStream baos)
close Ignore IO Ex
if (null == baos)
    return;
try {
    baos.close();
} catch (IOException ex) {
voidcloseIgnoringException(final Closeable closeable)
Closes java.io.Closeable instance ignoring IOException.
if (closeable == null)
    return;
try {
    closeable.close();
} catch (IOException ignored) {
voidcloseIgnoringExceptions(Closeable c)
Provides an implementation of closing a file for use in a finally block so you can correctly close a file without even more exception handling stuff.
if (c != null) {
    try {
        c.close();
    } catch (IOException ioe) {
voidcloseIgnoringExceptions(Closeable c)
Helper method use to close a Closeable ignoring eventual exception
try {
    if (c != null) {
        c.close();
} catch (Throwable _) {
voidcloseImage()
close Image
stream.close();
voidcloseIncludeGuard(String name, PrintWriter writer)
Typical C include guard footer from fully qualified like Strings
final String macroName = name.replace(".", "_").toUpperCase();
writer.println();
writer.println("#endif /* " + macroName + " */");
writer.println();
voidcloseInput(InputStream src)
close Input
src.close();
voidcloseInputStream(DataInputStream di)
Closes the given input stream.
try {
    if (di != null) {
        di.close();
} catch (IOException io) {
    System.out.println("Couldn't close Input Stream " + di);
InputStreamcloseInputStream(InputStream in)
Closes an input stream.
if (in != null) {
    try {
        in.close();
        in = null;
    } catch (IOException e) {
        System.err.println("Cobertura: Error closing input stream.");
        e.printStackTrace();
return in;