Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Java 推断资源的 Content-Type

Java Content-Type 大约 264 字

代码

使用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();
    }
}
阅读 1413 · 发布于 2020-05-25

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

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

扫描二维码关注我
昵称:
随便看看 换一批