Java 推断资源的 Content-Type

Java Content-Type About 264 words

代码

使用JDK7中引入的Files类的probeContentType方法。

获取的Content-Typeimage/pngimage/jpg等。

public static void main(String[] args) {
    try {
        String contentType = Files.probeContentType(Paths.get(""));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Views: 1,573 · Posted: 2020-05-25

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh