Here you can find the source of booleanAsByte(boolean val)
@Nonnull public static byte[] booleanAsByte(boolean val)
//package com.java2s; /***************************************************************************************** * *** BEGIN LICENSE BLOCK *****//from w w w . j a v a 2 s . c om * * Version: MPL 2.0 * * echocat jConscius, Copyright (c) 2010-2012 echocat * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * *** END LICENSE BLOCK ***** ****************************************************************************************/ import javax.annotation.Nonnull; public class Main { @Nonnull public static byte[] booleanAsByte(boolean val) { return new byte[] { val ? (byte) 1 : (byte) 0 }; } }