@Test(expected = ArrayIndexOutOfBoundsException.class) public void failure_ReadBit_2() { byte value = 0b01010101; ByteUtils.readBit(value, 8); }
public static int readBit(byte value, int position) { if (position > 7 || position < 0) { throw new ArrayIndexOutOfBoundsException("position must be 0 - 7."); } byte[] data = new byte[2]; data[1] = value; int dataValue = new BigInteger(data).intValue(); return dataValue >>> position; }
ByteUtils { public static int readBit(byte value, int position) { if (position > 7 || position < 0) { throw new ArrayIndexOutOfBoundsException("position must be 0 - 7."); } byte[] data = new byte[2]; data[1] = value; int dataValue = new BigInteger(data).intValue(); return dataValue >>> position; } }
ByteUtils { public static int readBit(byte value, int position) { if (position > 7 || position < 0) { throw new ArrayIndexOutOfBoundsException("position must be 0 - 7."); } byte[] data = new byte[2]; data[1] = value; int dataValue = new BigInteger(data).intValue(); return dataValue >>> position; }  }
ByteUtils { public static int readBit(byte value, int position) { if (position > 7 || position < 0) { throw new ArrayIndexOutOfBoundsException("position must be 0 - 7."); } byte[] data = new byte[2]; data[1] = value; int dataValue = new BigInteger(data).intValue(); return dataValue >>> position; }  static byte[][] split(byte[] input, int firstLength); static byte[] reverse(byte[] input); static byte[] join(byte[] value1, byte[] value2); static byte[] join(byte[]... inputs); static byte[] paddingZeroOnHead(byte[] input, int byteLength); static byte[] paddingZeroOnTail(byte[] input, int byteLength); static int readBit(byte value, int position); }
ByteUtils { public static int readBit(byte value, int position) { if (position > 7 || position < 0) { throw new ArrayIndexOutOfBoundsException("position must be 0 - 7."); } byte[] data = new byte[2]; data[1] = value; int dataValue = new BigInteger(data).intValue(); return dataValue >>> position; }  static byte[][] split(byte[] input, int firstLength); static byte[] reverse(byte[] input); static byte[] join(byte[] value1, byte[] value2); static byte[] join(byte[]... inputs); static byte[] paddingZeroOnHead(byte[] input, int byteLength); static byte[] paddingZeroOnTail(byte[] input, int byteLength); static int readBit(byte value, int position);  }