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

voidcloseReader(BufferedReader reader)
close Reader
if (Objects.isNull(reader)) {
    return;
try {
    reader.close();
} catch (IOException e) {
    e.printStackTrace();
voidcloseReader(final Reader reader)
Closes the given reader and swallows exceptions that may arise during the process.
try {
    reader.close();
} catch (IOException e) {
    System.err.println("Error closing " + reader + ": " + e);
voidcloseReader(Reader r)
close Reader
if (r != null)
    try {
        r.close();
    } catch (Exception e) {
voidcloseReader(Reader reader)
Close the given Java IO Reader and ignore any thrown exception.
if (reader != null) {
    try {
        reader.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    } catch (Throwable ex) {
        ex.printStackTrace();
voidcloseReader(Reader reader)
Closes the reader
try {
    reader.close();
} catch (IOException e) {
    e.printStackTrace();
    throw new RuntimeException("Unable to close the reader " + e.getMessage());
voidcloseReader(Reader rReader)
Closes a reader.
try {
    if (rReader != null) {
        rReader.close();
} catch (IOException ignored) {
voidcloseRelaxed(Closeable resource)
Close the given resource relaxed.
if (resource != null) {
    try {
        resource.close();
    } catch (IOException ignore) {
voidcloseReportFile()
close Report File
if (wor) {
    return;
File orepfile = new File(oreppath);
try (PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(orepfile, true)))) {
    pw.println("</REPORT>");
booleancloseResource(final Closeable aResource)
Closes a given resource.
boolean result = false;
if (aResource != null) {
    try {
        if (aResource instanceof Flushable) {
            ((Flushable) aResource).flush();
    } catch (IOException exception) {
    } finally {
...
voidcloseSafe(InputStream inputStream)
close Safe
if (inputStream != null) {
    inputStream.close();