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 { boolean[] bools = { true, false, false, true, true, true }; ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for (boolean bool : bools) { dos.writeBoolean(bool); } dos.flush(); for (byte b : baos.toByteArray()) { System.out.print(b); } } }