Here you can find the source of booleanToByte(boolean x)
public static byte[] booleanToByte(boolean x)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] booleanToByte(boolean x) { if (x) {//from w w w.j a v a 2 s. c o m return new byte[] { (byte) 1 }; } else { return new byte[] { (byte) 0 }; } } }