package framework.util; public class BitUtil { public static String toHexString(int i){ String s = Integer.toHexString(0x000000ff & i); s = s.trim().toUpperCase(); if(s.length()==1){ s = "0"+s; } return s; } public static int byte2Int(byte b){ return 0x000000ff & b; } /** * 转成16进制字符串 * @param bs * @return */ public static String toHexString(byte[] bs){ StringBuffer s = new StringBuffer(""); for(byte b : bs){ s.append(" ").append(BitUtil.toHexString(BitUtil.byte2Int(b))); } return s.toString().trim(); } }