text: public byte[] toArray() {if (arrays.isEmpty()) {return null;} else if (arrays.size() > 1) {int totalLength = 0;for (byte[] array : arrays) {totalLength += array.length;}byte[] concatenated = new byte[totalLength];int destPos = 0;for (byte[] array : arrays) {System.arraycopy(array, 0, concatenated, destPos, array.length);destPos += array.length;}arrays.clear();arrays.add(concatenated);}return arrays.get(0);}