Write byte array to file in java

FileOutputStream fos = FileOutputStream("path/to/the/file/to/write/in");
fos.write(theByteArray);
fos.close();

Will write the byte array in byte form.

FileOutputStream fos = FileOutputStream("path/to/the/file/to/write/in");
for (byte b : bytes) {
    fos.write(String.format("%02X ", b).getBytes());
}
fos.write(theByteArray);
fos.close();

Will write byte array in human readable form.

Source:
Java code To convert byte to Hexadecimal
http://docs.oracle.com/javase/7/docs/api/java/io/FileOutputStream.html

Browse More Popular Posts

Leave a Comment