Java Stream Close closeStream(final InputStream in)

Here you can find the source of closeStream(final InputStream in)

Description

Closes the given stream and swallows exceptions that may arise during the process.

License

Open Source License

Parameter

Parameter Description
in Input stream to close.

Declaration

public static void closeStream(final InputStream in) 

Method Source Code

//package com.java2s;
/* See LICENSE for licensing and NOTICE for copyright. */

import java.io.IOException;
import java.io.InputStream;

import java.io.OutputStream;

public class Main {
    /**/*  w  w w.j  a va 2s.co m*/
     * Closes the given stream and swallows exceptions that may arise during the
     * process.
     *
     * @param  in  Input stream to close.
     */
    public static void closeStream(final InputStream in) {
        try {
            in.close();
        } catch (IOException e) {
            System.err.println("Error closing " + in + ": " + e);
        }
    }

    /**
     * Closes the given stream and swallows exceptions that may arise during the
     * process.
     *
     * @param  out  Output stream to close.
     */
    public static void closeStream(final OutputStream out) {
        try {
            out.close();
        } catch (IOException e) {
            System.err.println("Error closing " + out + ": " + e);
        }
    }
}

Related

  1. closeStream(Closeable stream)
  2. closeStream(Closeable... closeable)
  3. closeStream(Closeable... streams)
  4. closeStream(FileInputStream in)
  5. closeStream(final Closeable stream)
  6. closeStream(final InputStream stream)
  7. closeStream(final java.io.Closeable stream)
  8. closeStream(final Object stream)
  9. closeStream(InputStream in)