是
public static String getEncoding(String str){ String encoding = "UTF-8"; try { if (str.equals(new String(str.getBytes(),encoding))) { return encoding; } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } encoding = "GBK"; try { if (str.equals(new String(str.getBytes(),encoding))) { return encoding; } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } encoding = "ISO-8859-1"; try { if (str.equals(new String(str.getBytes(),encoding))) { return encoding; } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } encoding = "GB2312"; try { if (str.equals(new String(str.getBytes(),encoding))) { return encoding; } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/17431.html