Class FileCharsetDetector



  • public class FileCharsetDetector
    extends java.lang.Object
    借助JCharDet获取文件字符集
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String guestFileEncoding​(java.io.File file)
      传入一个文件(File)对象,检查文件编码
      java.lang.String guestFileEncoding​(java.io.File file, int languageHint)
      获取文件的编码
      java.lang.String guestFileEncoding​(java.lang.String path)
      获取文件的编码
      java.lang.String guestFileEncoding​(java.lang.String path, int languageHint)
      获取文件的编码
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileCharsetDetector

        public FileCharsetDetector​()
    • Method Detail

      • guestFileEncoding

        public java.lang.String guestFileEncoding​(java.io.File file)
                                           throws java.io.FileNotFoundException,
                                                  java.io.IOException
        传入一个文件(File)对象,检查文件编码
        Parameters:
        file - File对象实例
        Returns:
        文件编码,若无,则返回null
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • guestFileEncoding

        public java.lang.String guestFileEncoding​(java.io.File file,
                                                  int languageHint)
                                           throws java.io.FileNotFoundException,
                                                  java.io.IOException
        获取文件的编码
        Parameters:
        file - File对象实例
        languageHint - 语言提示区域代码 eg:1 : Japanese; 2 : Chinese; 3 : Simplified Chinese; 4 : Traditional Chinese; 5 : Korean; 6 : Dont know (default)
        Returns:
        文件编码,eg:UTF-8,GBK,GB2312形式,若无,则返回null
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • guestFileEncoding

        public java.lang.String guestFileEncoding​(java.lang.String path)
                                           throws java.io.FileNotFoundException,
                                                  java.io.IOException
        获取文件的编码
        Parameters:
        path - 文件路径
        Returns:
        文件编码,eg:UTF-8,GBK,GB2312形式,若无,则返回null
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • guestFileEncoding

        public java.lang.String guestFileEncoding​(java.lang.String path,
                                                  int languageHint)
                                           throws java.io.FileNotFoundException,
                                                  java.io.IOException
        获取文件的编码
        Parameters:
        path - 文件路径
        languageHint - 语言提示区域代码 eg:1 : Japanese; 2 : Chinese; 3 : Simplified Chinese; 4 : Traditional Chinese; 5 : Korean; 6 : Dont know (default)
        Returns:
        Throws:
        java.io.FileNotFoundException
        java.io.IOException