Java InputStream Close close(InputStream in)

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

Description

Attempts to close the stream, suppressing all exceptions.

License

Open Source License

Parameter

Parameter Description
in the stream

Declaration

public static final void close(InputStream in) 

Method Source Code

//package com.java2s;

import java.io.InputStream;

import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.io.Writer;

public class Main {
    /**/*w  ww.  j av a  2  s. c  o  m*/
     * Attempts to close the stream, suppressing all exceptions.
     * 
     * @param in
     *            the stream
     */
    public static final void close(InputStream in) {
        try {
            in.close();
        } catch (Exception e) {
            // do nothing
        }
    }

    /**
     * Attempts to close the file, suppressing all exceptions.
     * 
     * @param raf
     *            the file
     * @param raf
     */
    public static final void close(RandomAccessFile raf) {
        try {
            raf.close();
        } catch (Exception e) {
            // do nothing
        }
    }

    /**
     * Attempts to close the stream, suppressing all exceptions.
     * 
     * @param out
     *            the stream
     */
    public static final void close(OutputStream out) {
        try {
            out.close();
        } catch (Exception e) {
            // do nothing
        }
    }

    /**
     * Attempts to close the reader, suppressing all exceptions.
     * 
     * @param in
     *            the reader
     */
    public static final void close(Reader in) {
        try {
            in.close();
        } catch (Exception e) {
            // do nothing
        }
    }

    /**
     * Attempts to close the writer, suppressing all exceptions.
     * 
     * @param out
     *            the writer
     */
    public static final void close(Writer out) {
        try {
            out.close();
        } catch (Exception e) {
            // do nothing
        }
    }
}

Related

  1. close(InputStream in)
  2. close(InputStream in)
  3. close(InputStream in)
  4. close(InputStream in)
  5. close(InputStream in)
  6. close(InputStream in)
  7. close(InputStream in, boolean silent)
  8. close(InputStream in, OutputStream out)
  9. close(InputStream input)