public static String getMimeTypeForFile ( String uri ) { int dot = uri . lastIndexOf ( ' ' ) ; String mime = null ; if ( dot >= 0 ) { mime = mimeTypes ( ) . get ( uri . substring ( dot + 1 ) . toLowerCase ( ) ) ; } return mime == null ? "application/octet-stream" : mime ; }
Get MIME type from file name extension if possible