Java Stream Close closeQuietly(Object object)

Here you can find the source of closeQuietly(Object object)

Description

close Quietly

License

Open Source License

Declaration

public static void closeQuietly(Object object) 

Method Source Code


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

import java.io.*;

public class Main {

    public static void closeQuietly(Object object) {
        if (object != null) {
            try {
                if (object instanceof Closeable) {
                    ((Closeable) object).close();
                } else if (object instanceof InputStream) {
                    ((InputStream) object).close();
                } else if (object instanceof OutputStream) {
                    ((OutputStream) object).close();
                } else if (object instanceof Reader) {
                    ((Reader) object).close();
                } else if (object instanceof Writer) {
                    ((Writer) object).close();
                }//from  ww w  .  j  a v a2s . co  m
            } catch (Exception e) {
            }
        }
    }
}

Related

  1. closeQuietly(InputStream x)
  2. closeQuietly(java.io.Closeable writer)
  3. closeQuietly(Object input)
  4. closeQuietly(Object obj)
  5. closeQuietly(Object object)
  6. closeQuietly(Object... o)
  7. closeQuietly(ObjectInput objectInput)
  8. closeQuietly(ObjectInput... objectInputs)
  9. closeQuietly(Reader input)