question: @ VisibleForTesting public static String fileName ( String url , String mimeType , String contentDisposition ) { String fileName = URLUtil . guessFileName ( url , contentDisposition , mimeType ) ; int dotIndex = fileName . lastIndexOf ( '.' ) ; if ( mimeType != null && ! mimeType . isEmpty ( ) && dotIndex > 1 && dotIndex < fileName . length ( ) ) { MimeTypeMap mimeTypeMap = MimeTypeMap . getSingleton ( ) ; String fileRoot = fileName . substring ( 0 , dotIndex ) ; String fileExtension = fileName . substring ( dotIndex + 1 ) ; String fileExtensionMimeType = mimeTypeMap . getMimeTypeFromExtension ( fileExtension ) ; if ( mimeType . equals ( fileExtensionMimeType ) ) { fileName = fileRoot + "." + fileExtension ; } else { String mimeExtension = mimeTypeMap . getExtensionFromMimeType ( mimeType ) ; if ( mimeExtension != null && ! mimeExtension . equals ( fileExtension ) ) { fileName = fileRoot + "." + mimeExtension ; } } } return fileName ; }
target:  Decide the file name of the final download. The file extension is derived from the MIME type.