byte[ ]数组 转换成16进制 字符数组

来源:互联网 发布:模拟电路图软件 编辑:程序博客网 时间:2024/06/10 06:46

转成16进制字符串



byte[] bs = new byte[6];        buff.get(bs);        sAddress = ByteUtilities.asHex(bs);


byte[ ]数组 转换成16进制 字符数组 

public String[] bytesToHexString(byte[] byteSrc)    {        //StringBuilder stringBuilder = new StringBuilder();                if (byteSrc == null || byteSrc.length <= 0)        {            return null;        }                String[] hexArray = new String[byteSrc.length];        for (int i = 0; i < byteSrc.length; i++)        {            int iHex = byteSrc[i] & 0xFF;            String sHex = Integer.toHexString(iHex);            if (sHex.length() < 2)            {                hexArray[i] = "0" + sHex;            }            else            {                hexArray[i] = sHex;            }                    }        return hexArray;    }


0 0