code: public static boolean close(final Object stream) {
        boolean success;
  
        if (stream instanceof InputStream) {
           success = close((InputStream) stream);
        } else if (stream instanceof OutputStream) {
           success = close((OutputStream) stream);
        } else {
           throw new IllegalArgumentException
                 ("stream is not an InputStream or OutputStream");
        }
  
        return success;
     }
docs: Attempt to close an <tt>InputStream</tt> or <tt>OutputStream</tt>.
  
  @param stream Stream to attempt to close.
  @return <tt>True</tt> if stream was closed (or stream was null), or
  <tt>false</tt> if an exception was thrown.
  @throws IllegalArgumentException Stream is not an <tt>InputStream</tt> or
  <tt>OuputStream</tt>.