public static String getContentType(String fileUrl) {
String contentType = null;
try {
contentType = new MimetypesFileTypeMap().getContentType(new File(fileUrl));
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("getContentType, File ContentType is : " + contentType);
return contentType;
}
END。
这篇博客介绍了如何使用Java的MimeTypesFileTypeMap类来获取文件URL的内容类型,并处理可能出现的异常。它展示了通过调用`getContentType`方法并打印结果,为开发者提供了一种常见文件类型识别的方法。
968

被折叠的 条评论
为什么被折叠?



