I have an array of integers which represent a RGB image and would like to convert it to a byte array and save it to a file.
What\'s the best way to convert an array
Maybe use this method
byte[] integersToBytes(int[] values) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for(int i=0; i < values.length; ++i) { dos.writeInt(values[i]); } return baos.toByteArray(); }