Java tutorial
import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { byte[] buf = { 12, 15, 18, 20, 22, 24 }; ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for (byte b : buf) { dos.writeByte(b); } dos.flush(); for (byte b : baos.toByteArray()) { System.out.print(b); } } }