@Override
    public boolean exists() {
        // Try file existence: can we find the file in the file system?
        if (isFile()) {
            try {
                return getFile().exists();
            } catch (IOException ex) {
                Logger logger = LogManager.getLogger(getClass());
                if (logger.isDebugEnabled()) {
                    logger.debug("Could not retrieve File for existence check of {}", getDescription(), ex);
                }
            }
        }
        // Fall back to stream existence: can we open the stream?
        try {
            getInputStream().close();
            return true;
        } catch (Throwable ex) {
            Logger logger = LogManager.getLogger(getClass());
            if (logger.isDebugEnabled()) {
                logger.debug("Could not retrieve InputStream for existence check of {}", getDescription(), ex);
            }
            return false;
        }
    }
This implementation checks whether a File can be opened,
falling back to whether an InputStream can be opened.
<p>This will cover both directories and content resources.
analyzer/src/main/java/nl/basjes/parse/useragent/utils/springframework/core/io/AbstractResource.java