Is there a simpler way to convert a byte array to a 2-byte-size hexadecimal string?
- by Tom Brito
Is there a simpler way of implement this? Or a implemented method in JDK or other lib?
/**
* Convert a byte array to 2-byte-size hexadecimal String.
*/
public static String to2DigitsHex(byte[] bytes) {
String hexData = "";
for (int i = 0; i < bytes.length; i++) {
int intV = bytes[i] & 0xFF; // positive int
String hexV =…