返回列表 發帖

tqc209

  1. import java.io.UnsupportedEncodingException;

  2. public class tqc209 {
  3.         public static void main(String[] args) throws UnsupportedEncodingException {
  4.                 String str="JAVA程式";
  5.                 String a=tohex(str);
  6.                 System.out.println(a);
  7.                 String toBig5=new String(str.getBytes("Big5"),"ISO8859_1");
  8.                 String b2hex=tohex(toBig5);
  9.                 System.out.println(b2hex);
  10.                 System.out.println(str);
  11.         }

  12.         private static String tohex(String str) {
  13.                 String rex="";
  14.                 char tmp;
  15.                 for(int i=0;i<str.length();i++){
  16.                         tmp=str.charAt(i);
  17.                         String t="0000"+Integer.toHexString(tmp);
  18.                         rex+=t.substring(t.length()-4)+" ";
  19.                 }
  20.                 return rex;
  21.         }
  22. }
複製代碼
陳彥綸

返回列表