วันจันทร์ที่ 25 กุมภาพันธ์ พ.ศ. 2551

java parse String to Decimal

// java parse String to Decimal

String thaiStr = "ก - ฮ นกเอี้ยง abc ABC \n \t";
Character ch;
String strNum;
Integer intNum;

for(int i=0; i<thaiStr.length(); i++){
ch = thaiStr.charAt(i);

System.out.println(" Char at : " + i + " " + ch);

strNum = Integer.toHexString(ch);

System.out.println(" Code String to 16 : " + strNum);

intNum = Integer.valueOf(strNum, 16);

System.out.println(" Code 16 to 10 : " + intNum);
System.out.println(" ------------------------ ");
}

ไม่มีความคิดเห็น: