zoukankan      html  css  js  c++  java
  • 判断字符串的编码

    /** 

    •      * 判断字符串的编码 
    •      * 
    •      * @param str 
    •      * @return 
    •      */  
    •     public static String getEncoding(String str) {  
    •         String encode = "GB2312";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s = encode;  
    •                 return s;  
    •             }  
    •         } catch (Exception exception) {  
    •         }  
    •         encode = "ISO-8859-1";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s1 = encode;  
    •                 return s1;  
    •             }  
    •         } catch (Exception exception1) {  
    •         }  
    •         encode = "UTF-8";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s2 = encode;  
    •                 return s2;  
    •             }  
    •         } catch (Exception exception2) {  
    •         }  
    •         encode = "GBK";  
    •         try {  
    •             if (str.equals(new String(str.getBytes(encode), encode))) {  
    •                 String s3 = encode;  
    •                 return s3;  
    •             }  
    •         } catch (Exception exception3) {  
    •         }  
    •         return "";  
    •     }  
    • }  
  • 相关阅读:
    (转)把hadoop源码关联到eclipse工程
    windows 系统下git 的使用
    windows 系统下git 的安装
    windows 系统下TortoiseGit 的安装
    windows 安装 mysql
    windows 下 mySQL 镜像安装文件下载
    vs2012 有效产品密钥
    mac 安装 visual studio 配置
    mac 安装 nodeJs&npm 配置
    macOS Sierra 如何打开任何来源
  • 原文地址:https://www.cnblogs.com/lbjz/p/3365292.html
Copyright © 2011-2022 走看看