List of utility methods to do Byte Array Create
byte[] | toByteArrayBE(byte b) to Byte Array BE byte[] result = new byte[1]; result[0] = b; return result; |
byte[] | toByteArrayForPBE(char[] chars) Convert the given char array into a byte array for use with PBE encryption. byte[] out = new byte[chars.length]; for (int i = 0; i < chars.length; i++) { out[i] = (byte) chars[i]; int length = out.length * 2; byte[] ret = new byte[length + 2]; int j = 0; for (int i = 0; i < out.length; i++) { ... |
byte[] | toByteArrayFromPositiveInts(int[] inInts) to Byte Array From Positive Ints if (inInts == null) { return null; final byte[] theBytes = new byte[inInts.length]; for (int i = 0; i < theBytes.length; i++) { theBytes[i] = positiveIntToByte(inInts[i]); return theBytes; ... |
byte[] | toByteArrayFromString(String value, int radix) Converts a string into a byte array. assert 16 == radix : "Specified string to byte array conversion not supported yet"; assert (value.length() % 2) == 0 : "Hex binary string must contain even number of characters"; byte[] ret = new byte[value.length() / 2]; for (int i = 0; i < ret.length; i++) { int digit1 = Character.digit(value.charAt(i * 2), radix); int digit2 = Character.digit(value.charAt((i * 2) + 1), radix); assert (digit1 != -1) && (digit2 != -1) : "String could not be converted to byte array"; ret[i] = (byte) ((digit1 * radix) + digit2); ... |
byte[] | toByteArrayLE(int value) to Byte Array LE byte[] bytes = new byte[4]; bytes[0] = (byte) (value); bytes[1] = (byte) (value >>> 8); bytes[2] = (byte) (value >>> 16); bytes[3] = (byte) (value >>> 24); return bytes; |
byte[] | toByteArrayMM(int value) to Byte Array MM return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) value }; |
byte[] | toByteArrayNoConversion(String textz) converts the specified string to an array of bytes (useful as Sleep stores byte arrays to strings) byte[] data = new byte[textz.length()]; for (int y = 0; y < data.length; y++) { data[y] = (byte) textz.charAt(y); return data; |
byte[] | toByteArrays(String s) to Byte Arrays final byte[] result = new byte[s.length() / 2]; for (int i = 0; i < result.length; i++) { result[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16); return result; |
byte[] | toByteArrayShifted(int... arguments) to Byte Array Shifted byte[] result = new byte[arguments.length]; for (int i = 0; i < arguments.length; i++) result[i] = (byte) (arguments[i] - 128); return result; |
byte[][] | toByteArrayShifted2(int[][] intArray) to Byte Array Shifted byte[][] result = new byte[intArray.length][]; for (int i = 0; i < intArray.length; i++) { result[i] = toByteArrayShifted(intArray[i]); return result; |