Java Hex转Ascii

public class HexToASCII {
	/**
	 * @param Hex字符串
	 * @return  将HEX字符串每两个一组截开,截成Hex数
	 */
	 public static List strSplit(String str){
		 List strList = new ArrayList();
//		 String[] strArray = new String[50];
		 boolean Flag = false;
		 if((str.length())%2 == 0){
			 Flag = true;
		 }
		 if(Flag){
			 for(int i=0;i<((str.length())/2);i++){
				 String substring = str.substring(0+i*2, 2+i*2);
//				 strArray[i] = substring;
				 strList.add(substring);
			 }
		 }
		return strList;
	    }
	 
	 
		/** 
		 * 16进制转化为字母 
		 * @param hex  要转化的16进制数,用逗号隔开     如:53,68,61,64,6f,77 
		 * @return 
		 */  
		public static String hexTolLetter(String hex) {  
		    StringBuilder sb = new StringBuilder();  
		    String[] split = hex.split(",");  
		    for (String str : split) {  
		        int i = Integer.parseInt(str, 16);  
		        sb.append((char)i);  
		    }  
		    return sb.toString();  
		}  
		
		
		/**
		 * @param str  Hex字符串
		 * @return     Hex字符串转换成ASCII的结果
		 */
		 public static String getASCII(String str) {
			 String returnStr = "";
			 List strSplitList = strSplit(str);
			 for(int i=0;i

 

你可能感兴趣的:(Java,ASCII,16进制)