@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)); } }
public static void putIntByteBuffer(ByteBuffer buf, int b) { buf.put((byte) (b & 0xFF)); }
BufferUtils { public static void putIntByteBuffer(ByteBuffer buf, int b) { buf.put((byte) (b & 0xFF)); } }
BufferUtils { public static void putIntByteBuffer(ByteBuffer buf, int b) { buf.put((byte) (b & 0xFF)); } private  BufferUtils(); }
BufferUtils { public static void putIntByteBuffer(ByteBuffer buf, int b) { buf.put((byte) (b & 0xFF)); } private  BufferUtils(); static int byteToInt(byte b); static synchronized void cleanDirectBuffer(ByteBuffer buffer); static ByteBuffer cloneByteBuffer(ByteBuffer buf); static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source); static void putIntByteBuffer(ByteBuffer buf, int b); static byte[] getIncreasingByteArray(int len); static byte[] getIncreasingByteArray(int start, int len); static boolean equalConstantByteArray(byte value, int len, byte[] arr); static boolean equalIncreasingByteArray(int len, byte[] arr); static boolean equalIncreasingByteArray(int start, int len, byte[] arr); static ByteBuffer getIncreasingByteBuffer(int len); static ByteBuffer getIncreasingByteBuffer(int start, int len); static boolean equalIncreasingByteBuffer(int start, int len, ByteBuffer buf); static void writeBufferToFile(String path, byte[] buffer); static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest); static int intAsUnsignedByteValue(int i); static byte[] newByteArrayFromByteBuffer(ByteBuffer buf); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position, int length); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position); }
BufferUtils { public static void putIntByteBuffer(ByteBuffer buf, int b) { buf.put((byte) (b & 0xFF)); } private  BufferUtils(); static int byteToInt(byte b); static synchronized void cleanDirectBuffer(ByteBuffer buffer); static ByteBuffer cloneByteBuffer(ByteBuffer buf); static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source); static void putIntByteBuffer(ByteBuffer buf, int b); static byte[] getIncreasingByteArray(int len); static byte[] getIncreasingByteArray(int start, int len); static boolean equalConstantByteArray(byte value, int len, byte[] arr); static boolean equalIncreasingByteArray(int len, byte[] arr); static boolean equalIncreasingByteArray(int start, int len, byte[] arr); static ByteBuffer getIncreasingByteBuffer(int len); static ByteBuffer getIncreasingByteBuffer(int start, int len); static boolean equalIncreasingByteBuffer(int start, int len, ByteBuffer buf); static void writeBufferToFile(String path, byte[] buffer); static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest); static int intAsUnsignedByteValue(int i); static byte[] newByteArrayFromByteBuffer(ByteBuffer buf); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position, int length); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position);  }