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);
|
}
|
}
|