Code example for FileChannel

Methods: size

0
 
    @Test 
    public void testMakeHead() throws Exception { 
        final IoBuffer head = this.fileMessageSet.makeHead(-1999, 100);
        assertEquals(0, head.position());
        assertTrue(head.hasRemaining());
        assertEquals("value 100 -1999\r\n", new String(head.array()));
    } 
 
 
    @Test 
    public void testSlice() throws Exception { 
        final long limit = 100;
        this.fileMessageSet.channel().position(limit);
        final ByteBuffer buf = ByteBuffer.allocate(1);
        buf.put((byte) 1);
        buf.flip();
        this.fileMessageSet.append(buf);
        this.fileMessageSet.setSizeInBytes(limit);
        this.fileMessageSet.flush();
        assertEquals(limit, this.fileMessageSet.highWaterMark());