@Test public void testConvertBits() throws Exception { assertEquals(1, ArraysUtil.convertBits(false, false, false, true)); assertEquals(127, ArraysUtil.convertBits(true, true, true, true, true, true, true)); assertEquals(74, ArraysUtil.convertBits(true, false, false, true, false, true, false)); }
public static byte convertBits(Boolean... bits) { StringBuilder number = new StringBuilder(); int i = 0; for (boolean bit : bits) { number.append(bit ? "1" : "0"); if (i == 7) { break; } i++; } return (byte) Integer.parseInt(number.toString(), 2); }
ArraysUtil { public static byte convertBits(Boolean... bits) { StringBuilder number = new StringBuilder(); int i = 0; for (boolean bit : bits) { number.append(bit ? "1" : "0"); if (i == 7) { break; } i++; } return (byte) Integer.parseInt(number.toString(), 2); } }
ArraysUtil { public static byte convertBits(Boolean... bits) { StringBuilder number = new StringBuilder(); int i = 0; for (boolean bit : bits) { number.append(bit ? "1" : "0"); if (i == 7) { break; } i++; } return (byte) Integer.parseInt(number.toString(), 2); } private  ArraysUtil(); }
ArraysUtil { public static byte convertBits(Boolean... bits) { StringBuilder number = new StringBuilder(); int i = 0; for (boolean bit : bits) { number.append(bit ? "1" : "0"); if (i == 7) { break; } i++; } return (byte) Integer.parseInt(number.toString(), 2); } private  ArraysUtil(); static BitSet getBitAddress(String ip); static int bytes2int(byte[] bytes); static byte[] combine(byte[]... bytes); static byte convertBits(Boolean... bits); static byte[] copy(byte[] source); static int getBit(byte _byte, int position); static byte[] int2bytes(int value); static byte[] int2bytesCropp(int value, int nbytes2cropp); static byte[] readBytes(byte[] source, int start); static byte[] readBytes(byte[] source, int start, int length); static byte reverseBitsByte(byte x); static byte setBit(byte _byte, int position, boolean value); }
ArraysUtil { public static byte convertBits(Boolean... bits) { StringBuilder number = new StringBuilder(); int i = 0; for (boolean bit : bits) { number.append(bit ? "1" : "0"); if (i == 7) { break; } i++; } return (byte) Integer.parseInt(number.toString(), 2); } private  ArraysUtil(); static BitSet getBitAddress(String ip); static int bytes2int(byte[] bytes); static byte[] combine(byte[]... bytes); static byte convertBits(Boolean... bits); static byte[] copy(byte[] source); static int getBit(byte _byte, int position); static byte[] int2bytes(int value); static byte[] int2bytesCropp(int value, int nbytes2cropp); static byte[] readBytes(byte[] source, int start); static byte[] readBytes(byte[] source, int start, int length); static byte reverseBitsByte(byte x); static byte setBit(byte _byte, int position, boolean value);  }