sf.net 上的Mime Type Detection Utility可能满足你的需要 http://sourceforge.net/projects/mime-util/ Enable Java programs to detect MIME types based on file extensions, magic data and content sniffing. Supports detection from java.io.File, java.io.InputStream, java.net.URL and byte arrays. See the project website www.medsea.eu/mime-util for details.
没有编码格式,.class文件里面怎么保存中文字符?
http://sourceforge.net/projects/mime-util/
Enable Java programs to detect MIME types based on file extensions, magic data and content sniffing. Supports detection from java.io.File, java.io.InputStream, java.net.URL and byte arrays. See the project website www.medsea.eu/mime-util for details.
用任何一种字符集打开这个文件都会得到乱码。所以,有意义么?
在明确知道字符串位于文件的某个位置的前提下,也许可以。