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

voidcloseWithoutError(Object close)
close the Closeable object, without any exception.
try {
    if (close == null) {
        return;
    if (close instanceof Closeable) {
        ((Closeable) close).close();
} catch (Exception e) {
...
voidcloseWithRuntimeException(Closeable c)
close With Runtime Exception
try {
    c.close();
} catch (IOException e) {
    throw new RuntimeException(e);
booleancloseWriteFile(FileOutputStream fileoutputstream)
close Write File
try {
    fileoutputstream.close();
    return true;
} catch (IOException ex) {
    System.err.println("File cannot be closed.");
    return false;
voidcloseWriter(final Writer writer)
If writer not null , close it and ignore IOException
if (writer != null) {
    try {
        writer.close();
    } catch (IOException e) {
voidcloseWriter(PrintWriter pw)
closes the given writer
if (pw != null) {
    pw.close();
voidcloseWriter(Writer writer)
close Writer
if (writer != null) {
    try {
        writer.close();
    } catch (IOException e) {
voidclosexBaseJProperty()
use this if you need to reset the property file which is usually left open
synchronized (props) {
    propFile = null;
    if (propIS != null) {
        try {
            propIS.close();
        } catch (IOException e) {
        propIS = null;
...
voidcloseXMLState(int toState)
output whatever is required to close the current xml for the current xml state.
if (spcOutputWriter != null) {
    if (toState == STATE_INIT) {
        if (xmlstate == STATE_CHILD_COMPLETE) {
            spcOutputWriter.write("</window></application></object>");
            spcOutputWriter.newLine();
        } else if (xmlstate == STATE_WIN) {
            spcOutputWriter.write(" /></application></object>");
            spcOutputWriter.newLine();
...
voidcloseZipOutputStreamQuietly(ZipOutputStream zipOutputStream)
Close an open ZipOutputStream without errormessages
try {
    zipOutputStream.finish();
    zipOutputStream.flush();
    zipOutputStream.close();
    zipOutputStream = null;
} catch (IOException e) {
} finally {
    if (zipOutputStream != null) {
...
voidcloseZipQuietly(@Nullable ZipFile file)
ZipFile does not implement Closeable on Java 6.
try {
    if (file != null) {
        file.close();
} catch (IOException ioe) {