Here you can find the source of setBit(byte data, byte bit, boolean value)
public static byte setBit(byte data, byte bit, boolean value)
//package com.java2s; //License from project: Open Source License public class Main { public static byte setBit(byte data, byte bit, boolean value) { if (value) { data = (byte) (data | (1 << bit)); } else {/*from w w w . ja v a 2 s . c om*/ data = (byte) (data & ~(1 << bit)); } return data; } }