Here you can find the source of setBit(byte input, int bit)
public static byte setBit(byte input, int bit)
//package com.java2s; //License from project: Apache License public class Main { private static final byte[] BYTE = new byte[] { -128, 64, 32, 16, 8, 4, 2, 1 }; public static byte setBit(byte input, int bit) { return (byte) (input | BYTE[bit]); }/* w w w . j av a2 s. c om*/ }