我怎样才能做到这一点?
您可以使用以下代码获取Java中文件的真实内容类型:
File file = new File("filename.asgdsag"); InputStream is = new BufferedInputStream(new FileInputStream(file)); String mimeType = URLConnection.guessContentTypeFromStream(is);