廖井涛
2024-03-04 eae17d27ec56a6b7887f5597335e38ca40273ef4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package toTcp;
 
import java.text.DecimalFormat;
 
import static com.sun.corba.se.impl.util.RepositoryId.getByteArray;
 
public class to16HEX {
 
    public static void to16Hex1(byte[] bytes, int len){
        byte[] afByte;
        //¶¨Òå16½øÖÆ×Ö·û´®
        String hex = "";
        for (int i = 0; i < len; i++) {
            int ce = bytes[i] & 0xFF;
            //ÕâÀï²»Âú×ãÁ½¸ö³¤¶ÈµÄÐèÒªÌî³ä0£¬ÎªÁËÂú×ãÒ»¸ö×Ö½ÚÕ¼µÄÊÇ×Ö·û´®µÄÁ½Î» ±ÈÈç 10µÄ16½øÖƾÍÊÇa ×ªÎª16½øÖÆ×Ö·û´®¾ÍÊÇ0a
            DecimalFormat df = new DecimalFormat("00");
            hex += " "+df.format(ce);
        }
        //afByte = getByteArray(hex);
        System.out.println(hex);
        System.out.println(len);
        //String result=new String(afByte, 0, afByte.length);
        //System.out.println(result);
    }
}