java 全角字符转半角

package test;
public class Test1 {

 /**
  *@author: zhangjp
  *@功能:测试全半角字符转换
  *@公用:true
  *@date:Jul 8, 2010 10:21:14 AM
  **/
 public static void main(String[] args) {
  // TODO Auto-generated method stub
      String quan = "11111";
     
      String ban = "11111";
      boolean  b = ban.equals(QJToBJChange(quan));
      System.out.println(b);
     
 }
 public static final String QJToBJChange(String QJStr)  
 {  
     char[] chr = QJStr.toCharArray();  
     String str = "";  
     for (int i = 0; i < chr.length; i++)  
     {  
         chr[i] = (char) ((int) chr[i] - 65248);  
         str += chr[i];  
     }  
     return str;  
 }
}

posted @ 2013-08-23 13:58  alaricblog  阅读(171)  评论(0编辑  收藏  举报