Here you can find the source of getMimeType(Path path)
Parameter | Description |
---|---|
path | the path to the file to probe. |
Parameter | Description |
---|---|
IOException | if something goes wrong. |
public static String getMimeType(Path path) throws IOException
//package com.java2s; import java.io.IOException; import java.nio.file.*; public class Main { /**//from w ww. j a va 2 s . c o m * Gets a file's content type. * * @param path the path to the file to probe. * @return the file content type. * @throws IOException if something goes wrong. */ public static String getMimeType(Path path) throws IOException { // An implementation using "Java Service Provider Interface (SPI)" is // registered in /META-INF/services/java.nio.file.spi.FileTypeDetector, // improving the standard default NIO implementation with the Apache Tika API. return Files.probeContentType(path); } }