Here you can find the source of setBits(final byte value, final int bitMask, final boolean val)
public static byte setBits(final byte value, final int bitMask, final boolean val)
//package com.java2s; // and/or modify it under the terms of the GNU General Public License public class Main { public static byte setBits(final byte value, final int bitMask, final boolean val) { byte mask = (byte) (0xFF ^ bitMask); byte tmp = (byte) (value & mask); if (val) { tmp |= bitMask;//w ww .ja v a2 s. c o m } return tmp; } }