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

voidcloseNoExceptions(Reader reader)
close No Exceptions
if (null == reader)
    return;
try {
    reader.close();
} catch (IOException e) {
    ; 
voidcloseNoThrow(InputStream s)
close No Throw
try {
    if (s != null) {
        s.close();
} catch (Exception ex) {
voidcloseOutput(OutputStream stream)
Close the given output stream.
if (stream == System.out) {
    return;
try {
    stream.close();
} catch (IOException ex) {
    throw new RuntimeException("trouble closing stream: " + stream, ex);
voidcloseOutputFile(Writer pWriter)
closes the outputfile
if (null != pWriter) {
    try {
        pWriter.flush();
    } catch (IOException e) {
        e.printStackTrace();
    try {
        pWriter.close();
...
voidcloseOutputStream(OutputStream out)
Closes and flushes the given OutputStream.
if (out != null) {
    try {
        out.flush();
    } catch (Exception ex) {
        ex.printStackTrace();
    try {
        out.close();
...
voidcloseOutputStream(OutputStream out, boolean flush)
Close the given output stream if not null
try {
    if (out != null) {
        if (flush)
            out.flush();
        out.close();
} catch (IOException e) {
voidcloseOutputStream(OutputStream outputStream)
close Output Stream
if (outputStream != null) {
    outputStream.close();
voidclosePermanentOutputWriter()
close Permanent Output Writer
if (outputWriter != null)
    try {
        outputWriter.close();
    } catch (IOException e) {
        e.printStackTrace();
voidclosePort()
close Port
isOpen = false;
try {
    p.getErrorStream().close();
    p.getInputStream().close();
    p.getOutputStream().close();
} catch (IOException e) {
    e.printStackTrace();
p.destroy();
voidclosePrintWriter(PrintWriter fileOutputStream)
close Print Writer
if (null != fileOutputStream) {
    fileOutputStream.flush();
    fileOutputStream.close();