Use both MimetypeFileTypeMap and FileNameMap (from URLConnection) to get

content type.

Use both MimetypeFileTypeMap and FileNameMap (from URLConnection) because MimetypeFileTypeMap provides a convenient way for the application to add new mappings, but doesn't provide any default mappings, while FileNameMap, from URLConnection, provides default mappings (via <java_home>/lib/content-types.properties) but without easy extensibility.