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

voidcloseStream(final Closeable stream)
close Stream
stream.close();
voidcloseStream(final InputStream in)
Closes the given stream and swallows exceptions that may arise during the process.
try {
    in.close();
} catch (IOException e) {
    System.err.println("Error closing " + in + ": " + e);
booleancloseStream(final InputStream stream)
Closes the InputStream, catching the exception and returning false on failure.
if (stream == null) {
    return false;
try {
    stream.close();
} catch (IOException e) {
    e.printStackTrace();
    return false;
...
voidcloseStream(final java.io.Closeable stream)
Closes the stream ignoring IOException .
cleanup(null, stream);
voidcloseStream(final Object stream)
Close an InputStream or OutputStream.
try {
    if (stream instanceof OutputStream) {
        OutputStream out = (OutputStream) stream;
        try {
            out.flush();
        } finally {
            out.close();
    } else if (stream instanceof InputStream) {
        ((InputStream) stream).close();
} catch (Exception e) {
voidcloseStream(InputStream in)
close Stream
close(in);
booleancloseStream(InputStream in)
close Stream
try {
    if (in != null) {
        in.close();
    return true;
} catch (IOException ioe) {
    return false;
voidcloseStream(InputStream inputStream)
close Stream
try {
    inputStream.close();
} catch (IOException e) {
voidcloseStream(InputStream ins)
close Stream
try {
    ins.close();
} catch (IOException e) {
voidcloseStream(Object oin)
close Stream
if (oin != null)
    try {
        if (oin instanceof InputStream)
            ((InputStream) oin).close();
        if (oin instanceof OutputStream)
            ((OutputStream) oin).close();
    } catch (IOException e) {
        e.printStackTrace();
...