To get the mime type of a file in Java you can use the following snippet.
Sample Java
String fileName = "/path/to/file.zip"; MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); String mimeType = mimeTypesMap.getContentType(fileName); File file = new File(fileName); mimeType = mimeTypesMap.getContentType(file); System.out.println(mimeType);
RT @CodeSnippetsNET: How to get the mime type of a file in #Java http://t.co/ahAxwrvvjn #programming #coding #dev