[New] Added StringHelper.asHexString()

This commit is contained in:
Robert von Burg 2017-05-26 15:02:15 +02:00
parent 53e4d5ce87
commit 7febff0de7
1 changed files with 4 additions and 4 deletions

View File

@ -56,6 +56,10 @@ public class StringHelper {
(byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd',
(byte) 'e', (byte) 'f' };
public static String asHexString(byte data) {
return String.format("%02x", data);
}
public static String asPrettyHexString(byte[] raw) {
try {
byte[] hex = new byte[3 * raw.length + (raw.length / 8)];
@ -81,10 +85,6 @@ public class StringHelper {
}
}
public static void main(String[] args) {
System.out.println(asPrettyHexString(fromHexString("010000000000040003000000000000c0")));
}
/**
* Converts each byte of the given byte array to a HEX value and returns the concatenation of these values
*