Java Stream Close closeOutput(OutputStream stream)

Here you can find the source of closeOutput(OutputStream stream)

Description

Close the given output stream.

License

Open Source License

Parameter

Parameter Description
stream non-null; the stream to close

Declaration

static public void closeOutput(OutputStream stream) 

Method Source Code

//package com.java2s;
// the rights to use, copy, modify, merge, publish, distribute, sublicense,

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    /**//from   ww w  .jav a2s.c o m
     * Close the given output stream.
     *
     * @param stream non-null; the stream to close
     */
    static public void closeOutput(OutputStream stream) {
        if (stream == System.out) {
            return;
        }

        try {
            stream.close();
        } catch (IOException ex) {
            throw new RuntimeException("trouble closing stream: " + stream, ex);
        }
    }
}

Related

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