Java Stream Close closeQuietly(Object obj)

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

Description

close Quietly

License

GNU General Public License

Declaration

public static void closeQuietly(Object obj) 

Method Source Code

//package com.java2s;
/*/*from   ww  w. ja v  a 2 s.  co  m*/
 * Copyright (C) 2015  University of Oregon
 *
 * You may distribute under the terms of either the GNU General Public
 * License or the Apache License, as specified in the README file.
 *
 * For more information, see the README file.
 */

import java.io.*;

public class Main {
    public static void closeQuietly(Object obj) {
        if (obj != null) {
            if (obj instanceof Closeable) {
                try {
                    ((Closeable) obj).close();
                } catch (Exception e) {
                }
            } else {
                throw new ClassCastException("Not a closable Object");
            }
        }
    }
}

Related

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