mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-15 05:13:08 -04:00
Added string to byte array function to ByteUtilities
This commit is contained in:
@@ -48,6 +48,17 @@ public class ByteUtilities {
|
||||
return new String(data);
|
||||
}
|
||||
|
||||
public static byte [] getHexStringArray(String string) {
|
||||
int len = string.length();
|
||||
if (len % 2 != 0)
|
||||
return new byte[0];
|
||||
byte[] data = new byte[len / 2];
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
data[i / 2] = (byte) ((Character.digit(string.charAt(i), 16) << 4) + Character.digit(string.charAt(i+1), 16));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte [] longToBytes(long l) {
|
||||
byte [] b = new byte[Long.SIZE];
|
||||
synchronized (buffer) {
|
||||
|
||||
Reference in New Issue
Block a user