List of usage examples for java.nio Buffer remaining
public final int remaining()
From source file:com.navercorp.pinpoint.common.buffer.FixedBufferTest.java
@Test public void test_remaining() throws Exception { final byte[] bytes = new byte[BytesUtils.INT_BYTE_LENGTH]; Buffer buffer = new FixedBuffer(bytes); Assert.assertEquals(buffer.remaining(), 4); Assert.assertTrue(buffer.hasRemaining()); buffer.putInt(1234);/* w ww . j a va 2 s.co m*/ Assert.assertEquals(buffer.remaining(), 0); Assert.assertFalse(buffer.hasRemaining()); buffer.setOffset(0); buffer.putShort((short) 12); Assert.assertEquals(buffer.remaining(), 2); Assert.assertTrue(buffer.hasRemaining()); buffer.putByte((byte) 1); Assert.assertEquals(buffer.remaining(), 1); Assert.assertTrue(buffer.hasRemaining()); }