Java Stream Close closeOutputStream(OutputStream out)

Here you can find the source of closeOutputStream(OutputStream out)

Description

Closes and flushes the given OutputStream.

License

Open Source License

Parameter

Parameter Description
out the OutputStream to close.

Declaration

public static void closeOutputStream(OutputStream out) 

Method Source Code

//package com.java2s;

import java.io.OutputStream;

public class Main {
    /**//from   w  ww  . jav  a  2 s  .c  om
     * Closes and flushes the given OutputStream.
     *
     * @param out the OutputStream to close.
     */
    public static void closeOutputStream(OutputStream out) {
        if (out != null) {
            try {
                out.flush();
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            try {
                out.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
}

Related

  1. closeNoException(Closeable... closeables)
  2. closeNoExceptions(Reader reader)
  3. closeNoThrow(InputStream s)
  4. closeOutput(OutputStream stream)
  5. closeOutputFile(Writer pWriter)
  6. closeOutputStream(OutputStream out, boolean flush)
  7. closeOutputStream(OutputStream outputStream)
  8. closePermanentOutputWriter()
  9. closePort()