Java 推断资源的 Content-Type
Java Content-Type About 264 words代码
使用JDK7中引入的Files类的probeContentType方法。
获取的Content-Type为image/png、image/jpg等。
public static void main(String[] args) {
try {
String contentType = Files.probeContentType(Paths.get(""));
} catch (IOException e) {
e.printStackTrace();
}
}
Views: 2,442 · Posted: 2020-05-25
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...