public String getContentType(String filePath) throws FileNotFoundException { String contenType = null; File file = new File(filePath); DataHandler hData = new DataHandler(new FileDataSource(file)); if (hData != null) { contenType = hData.getContentType(); } return contenType; }