Here you can find the source of getMimeType(String absolutePath)
public static String getMimeType(String absolutePath) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static String getMimeType(String absolutePath) throws IOException { Path path = Paths.get(absolutePath); return java.nio.file.Files.probeContentType(path); }/*from w w w. j a v a2 s .c o m*/ }