Java Stream Close closeQuietly(InputStream in)

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

Description

Close a stream

License

Apache License

Declaration

public static void closeQuietly(InputStream in) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    /** Close quietly */
    public static void closeQuietly(Reader in) {
        try {/*from  ww  w  .ja  va  2  s.  c om*/
            if (in != null)
                in.close();
        } catch (Throwable t) {
            System.out.println("[WARN] Unable to close input (e=" + t + ")");
        }
    }

    /** Close quietly */
    public static void closeQuietly(Writer out) {
        try {
            if (out != null)
                out.close();
        } catch (Throwable t) {
            System.out.println("[WARN] Unable to close output (e=" + t + ")");
        }
    }

    /** Close a stream */
    public static void closeQuietly(InputStream in) {
        try {
            if (in != null)
                in.close();
        } catch (Throwable t) {
            System.out.println("[WARN] Unable to close input (e=" + t + ")");
        }
    }
}

Related

  1. closeQuietly(final ZipFile... zipFiles)
  2. closeQuietly(ImageInputStream ins)
  3. closeQuietly(ImageReader iReader)
  4. closeQuietly(InputStream c)
  5. closeQuietly(InputStream in)
  6. closeQuietly(InputStream input)
  7. closeQuietly(InputStream input)
  8. closeQuietly(InputStream input)
  9. closeQuietly(InputStream input)