Java: MimeTypeMap fail to return extension for a filename contains spaces phptuts May 25, 2021 Sample error code: import android.webkit.MimeTypeMap; ... String extension = MimeTypeMap.getFileExtensionFromUrl(url); Solution: Replace blank space to %20 String extension = MimeTypeMap.getFileExtensionFromUrl(url.replace(" ","%20")); phptuts