Add toString method to Hex utils

This commit is contained in:
AsamK 2020-03-23 11:31:55 +01:00
parent bb06ae9d9a
commit 3f315df6c8
2 changed files with 10 additions and 2 deletions

View file

@ -9,6 +9,15 @@ public class Hex {
private Hex() {
}
public static String toString(byte[] bytes) {
StringBuffer buf = new StringBuffer();
for (final byte aByte : bytes) {
appendHexChar(buf, aByte);
buf.append(" ");
}
return buf.toString();
}
public static String toStringCondensed(byte[] bytes) {
StringBuffer buf = new StringBuffer();
for (final byte aByte : bytes) {
@ -20,7 +29,6 @@ public class Hex {
private static void appendHexChar(StringBuffer buf, int b) {
buf.append(HEX_DIGITS[(b >> 4) & 0xf]);
buf.append(HEX_DIGITS[b & 0xf]);
buf.append(" ");
}
public static byte[] toByteArray(String s) {