Package org.jtester.cpdetector

Examples of org.jtester.cpdetector.CodepageDetectorProxy


   *
   * @param file
   * @return
   */
  public static String getFileEncodingCharset(File file) {
    CodepageDetectorProxy detector = CodepageDetectorProxy.getInstance();
    detector.add(JChardetFacade.getInstance());

    try {
      Charset charset = Charset.forName(ResourceHelper.defaultFileEncoding());
      try {
        charset = detector.detectCodepage(file.toURL());
      } catch (IllegalArgumentException e) {
        charset = Charset.forName(ResourceHelper.defaultFileEncoding());
        JTesterLogger.warn("get file encoding error:" + e.getMessage() + ", use default encoding:"
            + ResourceHelper.defaultFileEncoding());
      }
View Full Code Here


   *
   * @param file
   * @return
   */
  public static String getFileEncodingCharset(InputStream is) {
    CodepageDetectorProxy detector = CodepageDetectorProxy.getInstance();
    detector.add(JChardetFacade.getInstance());

    try {
      Charset charset = Charset.forName(ResourceHelper.defaultFileEncoding());
      try {
        charset = detector.detectCodepage(is, 2147483647);
      } catch (IllegalArgumentException e) {
        charset = Charset.forName(ResourceHelper.defaultFileEncoding());
        JTesterLogger.warn("get file encoding error:" + e.getMessage() + ", use default encoding:"
            + ResourceHelper.defaultFileEncoding());
      }
View Full Code Here

TOP

Related Classes of org.jtester.cpdetector.CodepageDetectorProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.