How a certain output encoded string

Public String translate (String str) {

 String tempStr = “”;
 try {
 tempStr = new String(str.getBytes(“ISO-8859-1″), “GBK”);  //输出ISO-8859-1的字符串
 tempStr = tempStr.trim();
 }
 catch (Exception e) {
 System.err.println(e.getMessage());
 }
 return tempStr;
 }

Guess you like

Origin www.cnblogs.com/hurong07/p/11208115.html