Possible Duplicate:
How to convert an ArrayList containing Integers to primitive int array?
How to convert an ArrayList<Byte>
into a byte[]
?
ArrayList.toArray()
gives me back a Byte[]
.
byte[] result = new byte[list.size()];
for(int i = 0; i < list.size(); i++) {
result[i] = list.get(i).byteValue();
}
Yeah, Java's collections are annoying when it comes to primitive types.