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

voidcloseQuietly(Object... o)
Quietly close all specified input streams, output streams, readers, and writers.
for (Object o2 : o) {
    if (o2 instanceof InputStream)
        closeQuietly((InputStream) o2);
    if (o2 instanceof OutputStream)
        closeQuietly((OutputStream) o2);
    if (o2 instanceof Reader)
        closeQuietly((Reader) o2);
    if (o2 instanceof Writer)
...
voidcloseQuietly(ObjectInput objectInput)
Close the specified object input, ignoring any exceptions.
try {
    objectInput.close();
} catch (final Exception e) {
voidcloseQuietly(ObjectInput... objectInputs)
Close the specified object input, ignoring any exceptions.
for (final ObjectInput objectInput : objectInputs) {
    try {
        objectInput.close();
    } catch (final Exception e) {
voidcloseQuietly(Reader input)
Unconditionally closes an the Reader provided.
if (input != null) {
    try {
        input.close();
    } catch (Exception e) {
voidcloseQuietly(Reader r)
close Quietly
try {
    r.close();
} catch (IOException e) {
voidcloseQuietly(Reader reader)
close Quietly
try {
    if (reader != null) {
        reader.close();
} catch (IOException e) {
    e.printStackTrace();
voidcloseQuietly(Writer writer)
close Quietly
closeQuietly((Closeable) writer);
voidcloseQuietly(ZipFile closeable)
close Quietly
try {
    if (closeable != null)
        closeable.close();
} catch (Exception e) {
booleancloseQuietlyWithResult(InputStream sourceInput, boolean suppressionSourceExists)
Close input.
boolean closed = suppressionSourceExists;
if (sourceInput != null) {
    try {
        sourceInput.close();
    } catch (IOException ignored) {
        closed = false;
return closed;
voidcloseRandomAccessFile()
close Random Access File
if (randomAccessFile != null) {
    try {
        randomAccessFile.close();
    } catch (IOException e) {
        new IOException(e.getMessage());