public static String getFilenameFromHeader ( String url , String contentDisposition ) { String filename ; if ( ! TextUtils . isEmpty ( contentDisposition ) ) { int index = contentDisposition . indexOf ( "filename" ) ; if ( index > 0 ) { filename = contentDisposition . substring ( index + 9 , contentDisposition . length ( ) ) ; return filename ; } else { filename = getFilenameFromUrl ( url ) ; } } else { filename = getFilenameFromUrl ( url ) ; } try { filename = URLDecoder . decode ( filename , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { /* ignore */ } return filename ; }
Get filename from content disposition in header .