ArrayConverters { public static byte[] convertIntegersToBytes(int[] intArray) { ByteBuffer bb = ByteBuffer.allocate(intArray.length); for(int i=0; i < intArray.length; ++i) { bb.put((byte)(int) intArray[i]); } return bb.array(); }  static String[] decodeChainList(byte[] currentChainList, int length); static float[] convertIntsToFloats(int[] intArray, float floatDivider); static int[] convertByteToIntegers(byte[] byteArray); static int[] convertTwoByteToIntegers(byte[] byteArray); static short[] convertTwoBytesToShorts(byte[] byteArray); static int[] convertFourByteToIntegers(byte[] byteArray); static int[] combineIntegers(int[] twoByteIntArray, int[] fourByteIntArray); static char[] convertIntegerToChar(int[] integerArray); static byte[] convertIntegersToBytes(int[] intArray); static byte[] convertIntegersToTwoBytes(int[] intArray); static byte[] convertShortsToTwoBytes(short[] shortArray); static byte[] convertIntegersToFourByte(int[] intArray); static int[] convertFloatsToInts(float[] floatArray, float floatMultiplier); static List<int[]> splitIntegers(int[] inputArray); static int[] convertCharToIntegers(char[] charArray); static byte[] encodeChainList(String[] chainNames, int length); static int[] recursiveIndexEncode(int[] in); static int[] recursiveIndexDecode(int[] in);  }
@Test public void integersToOneByteTest() { int[] intArray = {12,123,24}; byte[] testByteArray = {(byte) 12,(byte) 123, (byte) 24}; byte[] byteArray = ArrayConverters.convertIntegersToBytes(intArray); assertArrayEquals(testByteArray, byteArray); }