private static long getFileSizeFromUrl(String url) {
        if (!url.toLowerCase().startsWith("http")) {
            return -1;
        }

        final Request request = new Request.Builder().url(url).head().build();
        long respLength = -1;
        try (Response response = MVHttpClient.getInstance().getReducedTimeOutClient().newCall(request).execute();
             ResponseBody body = response.body()) {
            if (response.isSuccessful())
                respLength = body.contentLength();
        } catch (IOException ignored) {
            respLength = -1;
        }

        if (respLength < 1_000_000) {
            // alles unter 1MB sind Playlisten, ORF: Trailer bei im Ausland gesperrten Filmen, ...
            // dann wars nix
            respLength = -1;
        }
        return respLength;
    }
private static long getFileSizeFromUrl ( String url ) { if ( ! url . toLowerCase ( ) . startsWith ( "http" ) ) { return - 1 ; } final Request request = new Request . Builder ( ) . url ( url ) . head ( ) . build ( ) ; long respLength = - 1 ; try ( Response response = MVHttpClient . getInstance ( ) . getReducedTimeOutClient ( ) . newCall ( request ) . execute ( ) ; ResponseBody body = response . body ( ) ) { if ( response . isSuccessful ( ) ) respLength = body . contentLength ( ) ; } catch ( IOException ignored ) { respLength = - 1 ; } if ( respLength < 1_000_000 ) { respLength = - 1 ; } return respLength ; }
Return the size of a URL in bytes.

@param url URL as String to query.
@return size in bytes or -1.