public static String asciiToString(String value)
{
StringBuffer sbu = new StringBuffer();
String[] chars = value.split(",");
for (int i = 0; i < chars.length; i++) {
sbu.append((char) Integer.parseInt(chars[i]));
}
return sbu.toString();
測試方法及結果
public static void main(String[] args) {
String str = "彭玉軍";
String asciiResult = stringToAscii(str);
System.out.println(asciiResult);
String stringResult = asciiToString(asciiResult);
System.out.println(stringResult);
控制檯輸出 24429,29577,20891 彭玉軍
public static String asciiToString(String value)
{
StringBuffer sbu = new StringBuffer();
String[] chars = value.split(",");
for (int i = 0; i < chars.length; i++) {
sbu.append((char) Integer.parseInt(chars[i]));
}
return sbu.toString();
}
測試方法及結果
public static void main(String[] args) {
String str = "彭玉軍";
String asciiResult = stringToAscii(str);
System.out.println(asciiResult);
String stringResult = asciiToString(asciiResult);
System.out.println(stringResult);
}
控制檯輸出 24429,29577,20891 彭玉軍