/**
* ASCII码转中文
*
* @param ascii
* @return
*/
public static String ASCIItoString(String ascii) {
StringBuffer stringBuffer = new StringBuffer();
String[] chars = ascii.split(" ");
for (int i = 0; i < chars.length; i++) {
stringBuffer.append((char) Integer.parseInt(chars[i]));
}
return stringBuffer.toString();
}
/**
* 中文转ASCII码
*
* @param string
* @return
*/
public static String StringToASCII(String string) {
//把字符中转换为字符数组
char[] chars = string.toCharArray();
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
stringBuffer.append((int) chars[i]);
stringBuffer.append(" ");
}
return stringBuffer.toString();
}