library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadUtils.java
public static String parseContentDisposition(String contentDisposition) {
        if (contentDisposition == null) {
            return null;
        }

        try {
            Matcher m = CONTENT_DISPOSITION_WITH_ASTERISK_PATTERN.matcher(contentDisposition);
            if (m.find()) {
                String charset = m.group(1);
                String encodeFileName = m.group(2);
                return URLDecoder.decode(encodeFileName, charset);
            }

            m = CONTENT_DISPOSITION_WITHOUT_ASTERISK_PATTERN.matcher(contentDisposition);
            if (m.find()) {
                return m.group(1);
            }
        } catch (IllegalStateException | UnsupportedEncodingException ignore) {
            // This function is defined as returning null when it can't parse the header
        }
        return null;
    }
public static String parseContentDisposition(String contentDisposition) {
        if (contentDisposition == null) {
            return null;
        }

        try {
            Matcher m = CONTENT_DISPOSITION_WITH_ASTERISK_PATTERN.matcher(contentDisposition);
            if (m.find()) {
                String charset = m.group(1);
                String encodeFileName = m.group(2);
                return URLDecoder.decode(encodeFileName, charset);
            }

            m = CONTENT_DISPOSITION_WITHOUT_ASTERISK_PATTERN.matcher(contentDisposition);
            if (m.find()) {
                return m.group(1);
            }
        } catch (IllegalStateException | UnsupportedEncodingException ignore) {
            // This function is defined as returning null when it can't parse the header
        }
        return null;
    }
public static String parseContentDisposition ( String contentDisposition ) { if ( contentDisposition == null ) { return null ; } try { Matcher m = CONTENT_DISPOSITION_WITH_ASTERISK_PATTERN . matcher ( contentDisposition ) ; if ( m . find ( ) ) { String charset = m . group ( 1 ) ; String encodeFileName = m . group ( 2 ) ; return URLDecoder . decode ( encodeFileName , charset ) ; } m = CONTENT_DISPOSITION_WITHOUT_ASTERISK_PATTERN . matcher ( contentDisposition ) ; if ( m . find ( ) ) { return m . group ( 1 ) ; } } catch ( IllegalStateException | UnsupportedEncodingException ignore ) { // This function is defined as returning null when it can't parse the header } return null ; }
The same to com.android.providers.downloads.Helpers#parseContentDisposition.
</p>
Parse the Content-Disposition HTTP Header. The format of the header
is defined here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html
This header provides a filename for content that is going to be
downloaded to the file system. We only support the attachment type.
The same to com . android . providers . downloads . Helpers#parseContentDisposition . < / p > Parse the Content - Disposition HTTP Header . The format of the header is defined here : http : // www . w3 . org / Protocols / rfc2616 / rfc2616 - sec19 . html This header provides a filename for content that is going to be downloaded to the file system . We only support the attachment type .