@Override
    public long contentLength() throws IOException {
        URL url = getURL();
        if (ResourceUtils.isFileURL(url)) {
            // Proceed with file system resolution
            File file = getFile();
            long length = file.length();
            if (length == 0L && !file.exists()) {
                throw new FileNotFoundException(getDescription() +
                    " cannot be resolved in the file system for checking its content length");
            }
            return length;
        } else {
            // Try a URL connection content-length header
            URLConnection con = url.openConnection();
            customizeConnection(con);
            if (con instanceof HttpURLConnection) {
                HttpURLConnection httpCon = (HttpURLConnection) con;
                httpCon.setRequestMethod("HEAD");
            }
            return con.getContentLengthLong();
        }
    }
This implementation returns a File reference for the given URI-identified
resource, provided that it refers to a file in the file system.

see org.springframework.util.ResourceUtils#getFile(java.net.URI, String)
analyzer/src/main/java/nl/basjes/parse/useragent/utils/springframework/core/io/AbstractFileResolvingResource.java