Android byte[] 轉 string

直接上代碼,可直接用:java

private final static byte[] hex = "0123456789ABCDEF".getBytes();

public static String Bytes2HexString(byte[] b) {
byte[] buff = new byte[2 * b.length];
for (int i = 0; i < b.length; i++) {
buff[2 * i] = hex[(b[i] >> 4) & 0x0f];
buff[2 * i + 1] = hex[b[i] & 0x0f];
}
return new String(buff);
}

建了個交流羣:416157653,歡迎你們加入討論code

相關文章
相關標籤/搜索