Java InputStream Close close(InputStream is)

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

Description

Closes an input stream ignoring any errors.

License

Open Source License

Parameter

Parameter Description
is the stream to close, can be null

Declaration

public static void close(InputStream is) 

Method Source Code

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

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

import java.io.OutputStream;
import java.io.Reader;

import java.io.Writer;

public class Main {
    /**/*  ww w .j  av a 2 s.  co  m*/
     * Closes an input stream ignoring any errors.
     *
     * @param is the stream to close, can be null
     */
    public static void close(InputStream is) {
        if (is == null)
            return;
        try {
            is.close();
        } catch (IOException ignoreEx) {
        }
    }

    /**
     * Closes an output stream ignoring any errors.
     *
     * @param os the stream to close, can be null
     */
    public static void close(OutputStream os) {
        if (os == null)
            return;
        try {
            os.close();
        } catch (IOException ignoreEx) {
        }
    }

    /**
     * Closes a reader ignoring any errors.
     *
     * @param reader the reader to close, can be null
     */
    public static void close(Reader reader) {
        if (reader == null)
            return;
        try {
            reader.close();
        } catch (IOException ignoreEx) {
        }
    }

    /**
     * Closes a writer ignoring any errors.
     *
     * @param writer the writer to close, can be null
     */
    public static void close(Writer writer) {
        if (writer == null)
            return;
        try {
            writer.close();
        } catch (IOException ignoreEx) {
        }
    }
}

Related

  1. close(InputStream inputStream)
  2. close(InputStream inputstream)
  3. close(InputStream inputStream)
  4. close(InputStream is)
  5. close(InputStream is)
  6. close(InputStream is)
  7. close(InputStream is)
  8. close(InputStream is)
  9. close(InputStream is)