判断字符串编码类型

    public static String getEncoding(String str) {  
        String encode = "GBK";  
        try {  
            if (str.equals(new String(str.getBytes(encode), encode))) {  
                return encode;    
            }  
        } catch (Exception exception) { ... }  
  
        encode = "UTF-8"  
        encode = "SJIS"  
    }


你可能感兴趣的:(java)