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

voidcloseSilently(OutputStream outputStream)
Closes the OutputStream, ignoring any exceptions raised while closing.
flushSilently(outputStream);
try {
    outputStream.close();
} catch (IOException ignored) {
voidcloseStatusFile(PrintWriter pwStatusFile)
This will close the status file.
if (pwStatusFile != null) {
    pwStatusFile.close();
    pwStatusFile = null;
voidcloseStream(Closeable aStream)
Silently closes the given stream.
try {
    aStream.close();
} catch (Exception ex) {
voidcloseStream(Closeable closeable)
check null and Close a stream
if (closeable != null) {
    closeable.close();
voidcloseStream(Closeable closeable)
Convenience method for closing streams that swallows the IOException that could be thrown during closing.
if (closeable != null) {
    try {
        closeable.close();
    } catch (IOException e) {
voidcloseStream(Closeable stream)
Close IO stream safely.
try {
    if (stream != null) {
        stream.close();
} catch (IOException e) {
    System.out.println("Close IO stream failure.");
    e.printStackTrace();
voidcloseStream(Closeable stream)
close Stream
try {
    stream.close();
} catch (IOException e) {
    throw new IllegalArgumentException(stream + " can not close", e);
voidcloseStream(Closeable... closeable)
close Stream
for (Closeable c : closeable) {
    if (c != null) {
        try {
            c.close();
        } catch (IOException ignored) {
voidcloseStream(Closeable... streams)
close Stream
if (streams == null)
    return;
for (Closeable stream : streams) {
    CloseOneStream(stream);
voidcloseStream(FileInputStream in)
close Stream
if (in != null) {
    try {
        in.close();
    } catch (IOException e) {
        e.printStackTrace();