Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static byte[] toByteArray(Collection<? extends Number> c) { byte arr[] = new byte[c.size()]; int i = 0; for (Number item : c) { arr[i++] = item.byteValue(); } return arr; } }