Java InputStream Close close(InputStream in)

Here you can find the source of close(InputStream in)

Description

Safe close of an InputStream (no exceptions, even if reference is null).

License

Open Source License

Parameter

Parameter Description
in the stream to close

Declaration

public static void close(InputStream in) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    /**//from ww  w  . j  a v a 2s .  c om
     * Safe close of an OutputStream (no exceptions,
     * even if reference is null).
     *
     * @param out the stream to close
     */
    public static void close(OutputStream out) {
        try {
            out.close();
        } catch (Exception ignore) {
        }
    }

    /**
     * Safe close of an InputStream (no exceptions,
     * even if reference is null).
     *
     * @param in the stream to close
     */
    public static void close(InputStream in) {
        try {
            in.close();
        } catch (Exception ignore) {
        }
    }
}

Related

  1. close(InputStream closeable)
  2. close(InputStream in)
  3. close(InputStream in)
  4. close(InputStream in)
  5. close(InputStream in)
  6. close(InputStream in)
  7. close(InputStream in)