java 判断字符串什么编码类型

     public static String getEncodingString str) {    
         String encode = "GB2312";    
        try {    
            if str.equalsnew Stringstr.getBytesencode), encode))) {    
                 String s = encode;    
                return s;    
             }    
         } catch Exception exception) {    
         }    
         encode = "ISO-8859-1";    
        try {    
            if str.equalsnew Stringstr.getBytesencode), encode))) {    
                 String s1 = encode;    
                return s1;    
             }    
         } catch Exception exception1) {    
         }    
         encode = "UTF-8";    
        try {    
            if str.equalsnew Stringstr.getBytesencode), encode))) {    
                 String s2 = encode;    
                return s2;    
             }    
         } catch Exception exception2) {    
         }    
         encode = "GBK";    
        try {    
            if str.equalsnew Stringstr.getBytesencode), encode))) {    
                 String s3 = encode;    
                return s3;    
             }    
         } catch Exception exception3) {    
         }    
        return "";    
     }    
 String encode = "ISO-8859-1";     //应用延伸 
            try {      
                if customer.equalsnew Stringcustomer.getBytesencode), encode))) {      
                    customer = new Stringcustomer.getBytesencode),"utf-8");
                 }      
             } catch Exception exception1) {      
             }  

Published by

风君子

独自遨游何稽首 揭天掀地慰生平