public static void putIntByteBuffer(ByteBuffer buf, int b) {
    buf.put((byte) (b & 0xFF));
  }
@Test
  public void putIntByteBuffer() {
    class TestCase {
      byte mExpected;
      int mInput;

      public TestCase(byte expected, int input) {
        mExpected = expected;
        mInput = input;
      }
    }

    ArrayList<TestCase> testCases = new ArrayList<>();
    testCases.add(new TestCase((byte) 0x00, 0x00));
    testCases.add(new TestCase((byte) 0x12, 0x12));
    testCases.add(new TestCase((byte) 0x34, 0x1234));
    testCases.add(new TestCase((byte) 0x56, 0x123456));
    testCases.add(new TestCase((byte) 0x78, 0x12345678));

    for (TestCase testCase : testCases) {
      ByteBuffer buf = ByteBuffer.allocate(1);
      BufferUtils.putIntByteBuffer(buf, testCase.mInput);
      assertEquals(testCase.mExpected, buf.get(0));
    }
  }