Here you can find the source of toByteArray(ArrayList
public static byte[] toByteArray(ArrayList<Byte> in)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static byte[] toByteArray(ArrayList<Byte> in) { int n = in.size(); byte ret[] = new byte[n]; for (int x = 0; x < n; x++) { ret[x] = in.get(x);/*from w w w. j a va2s. com*/ } return ret; } }