将byte转换为一个长度为8的boolean数组（每bit代表一个boolean值）

@param b byte
@return boolean数组
16459
public static boolean[] byte2Booleans(byte b) {
        boolean[] array = new boolean[8];
        for (int i = 7; i >= 0; i--) { //对于byte的每bit进行判定
            array[i] = (b & 1) == 1; //判定byte的最后一位是否为1，若为1，则是true；否则是false
            b = (byte) (b >> 1); //将byte右移一位
        }
        return array;
    }
582693
public static Bytes toBytes(ByteSequence bs) {
    if (bs.length() == 0) {
      return Bytes.EMPTY;
    }

    if (bs.isBackedByArray()) {
      return Bytes.of(bs.getBackingArray(), bs.offset(), bs.length());
    } else {
      return Bytes.of(bs.toArray(), 0, bs.length());
    }
  }
1112813
public static byte[] appendByte(byte[] bytes, byte b) {
        byte[] result = Arrays.copyOf(bytes, bytes.length + 1);
        result[result.length - 1] = b;
        return result;
    }
829150
static byte[] convertBoolArrayToByteArray(boolean[] boolArr) {
    byte[] byteArr = new byte[(boolArr.length + 7) / 8];
    for (int i = 0; i < byteArr.length; i++) {
      byteArr[i] = readByte(boolArr, 8 * i);
    }
    return byteArr;
  }
924131
private static String byte2hex(byte b[]) {
		StringBuilder sb = new StringBuilder();
		for (int n = 0; n < b.length; n++) {
			String stmp = Integer.toHexString(b[n] & 0xff);
			if (stmp.length() == 1) {
				// hs = hs + "0" + stmp;
				sb.append("0");
			}
			sb.append(stmp);
			// else {
			// // hs = hs + stmp;
			// }
		}

		return sb.toString().toUpperCase();
	}
496537
def add_boolean(self, b):
        
        if b:
            self.packet.write(one_byte)
        else:
            self.packet.write(zero_byte)
        return self
507791
public static String toHexString(byte[] b) {
        StringBuilder sb = new StringBuilder(b.length * 2);
        for (byte aByte : b) {
            // look up high nibble char
            sb.append(hexChar[(aByte & 0xf0) >>> 4]);

            // look up low nibble char
            sb.append(hexChar[aByte & 0x0f]);
        }
        return sb.toString();
    }
281227
public static int getNumSetBits(ByteBuffer bfBuffer, int start)
  {
    ByteBuffer view = bfBuffer.duplicate().order(ByteOrder.BIG_ENDIAN);
    view.position(start);
    int numLongs = view.getInt(1 + start);
    int setBits = 0;
    for (int i = 0, pos = START_OF_SERIALIZED_LONGS + start; i < numLongs; i++, pos += Long.BYTES) {
      setBits += Long.bitCount(view.getLong(pos));
    }
    return setBits;
  }
327279
public final static String toHex(byte [] b) {
	char[] buf = new char[b.length * 2];
	int i, j, k;

	i = j = 0;
	for (; i < b.length; i++) {
	    k = b[i];
	    buf[j++] = hex[(k >>> 4) & 0x0F];
	    buf[j++] = hex[ k & 0x0F];
	}
	return new String(buf);
    }
1106929
public int read(byte b[]) throws IOException
    {
        int len = b.length;
        if (_chunkSize<=0 && getChunkSize()<=0)
            return -1;
        if (len > _chunkSize)
            len=_chunkSize;
        len=_in.read(b,0,len);
        if (len<0)
        {
            _chunkSize=-1;
            throw new IOException(__UNEXPECTED_EOF);
        }
        _chunkSize=_chunkSize-len;
        return len;
    }
237292
public static String toHexString(byte[] b) {
        if (b == null)
            return null;

        StringBuilder sb = new StringBuilder(b.length * 2);
        for (int i = 0; i < b.length; i++) {
            int v = b[i] & 0xFF;
            String hv = Integer.toHexString(v);
            if (hv.length() < 2) {
                sb.append(0);
            }
            sb.append(hv);
        }
        return sb.toString();
    }
605424
public static byte reverseBitsInByte(final JBBPBitNumber bitNumber, final byte value) {
    final byte reversed = reverseBitsInByte(value);
    return (byte) ((reversed >>> (8 - bitNumber.getBitNumber())) & bitNumber.getMask());
  }
387760
private static int get16(byte[] b, int off) {
        return Byte.toUnsignedInt(b[off]) | ( Byte.toUnsignedInt(b[off+1]) << 8);
    }
906762
public static int bitCount(final byte[] data) {
        int count = 0;
        for (final byte element : data) {
            byte bits = element;
            for (int j = 0; j < 8; j++) {
                if ((bits & 1) == 1) {
                    count++;
                }
                bits >>= 1;
            }
        }
        return count;
    }
205674
public BEValue bdecodeBytes() throws IOException {
    int c = this.getNextIndicator();
    int num = c - '0';
    if (num < 0 || num > 9)
      throw new InvalidBEncodingException("Number expected, not '"
              + (char) c + "'");
    this.indicator = 0;

    c = this.read();
    int i = c - '0';
    while (i >= 0 && i <= 9) {
      // This can overflow!
      num = num * 10 + i;
      c = this.read();
      i = c - '0';
    }

    if (c != ':') {
      throw new InvalidBEncodingException("Colon expected, not '" +
              (char) c + "'");
    }

    return new BEValue(read(num));
  }
1044489
public static String byteToHex(byte b[]) {

        int    len = b.length;
        char[] s   = new char[len * 2];

        for (int i = 0, j = 0; i < len; i++) {
            int c = ((int) b[i]) & 0xff;

            s[j++] = HEXCHAR[c >> 4 & 0xf];
            s[j++] = HEXCHAR[c & 0xf];
        }

        return new String(s);
    }
1023702
public boolean getBoolean() {
        byte result = buffer.getByte(index + offset);
        index += Bits.BYTE_SIZE_IN_BYTES;
        return result != 0;
    }