Here you can find the source of toByteArray(int[] data, boolean includeLength)
private static byte[] toByteArray(int[] data, boolean includeLength)
//package com.java2s; public class Main { private static byte[] toByteArray(int[] data, boolean includeLength) { int n = data.length << 2; if (includeLength) { int m = data[data.length - 1]; n -= 4;//w w w. j a v a 2 s . co m if ((m < n - 3) || (m > n)) { return null; } n = m; } byte[] result = new byte[n]; for (int i = 0; i < n; ++i) { result[i] = (byte) (data[i >>> 2] >>> ((i & 3) << 3)); } return result; } }