class ByteArrayUtil {

  public static int threeBytesToInt(byte[] bytes, int offset) {
    if (bytes == null || bytes.length < offset + 3 || offset < 0) {
      throw new IllegalArgumentException("Bad data for converting 3-byte integers.");
    }
    return (bytes[offset] & 0xFF) << 16
        | (bytes[offset + 1] & 0xFF) << 8
        | (bytes[offset + 2] & 0xFF);
  }

  private  ByteArrayUtil();

}