Package org.uberfire.java.nio.channels

Examples of org.uberfire.java.nio.channels.SeekableByteChannel.position()


        final SeekableByteChannel sbc = new SeekableByteChannelFileBasedImpl( new RandomAccessFile( tempFile, "rw" ).getChannel() );

        assertTrue( sbc.isOpen() );
        sbc.write( ByteBuffer.wrap( "CONTENT\n?!".getBytes() ) );

        sbc.position( 0L );
        ByteBuffer buffer = ByteBuffer.allocate( 10 );
        sbc.read( buffer );
        assertEquals( "CONTENT\n?!", new String( buffer.array() ) );

        sbc.close();
View Full Code Here


        final SeekableByteChannel sbc = new SeekableByteChannelFileBasedImpl( new RandomAccessFile( tempFile, "rw" ).getChannel() );

        assertTrue( sbc.isOpen() );
        sbc.write( ByteBuffer.wrap( "CONTENT\n?!".getBytes() ) );

        assertEquals( 10L, sbc.position() );
        assertEquals( 10L, sbc.size() );

        sbc.position( 1L );
        ByteBuffer buffer = ByteBuffer.allocate( 8 );
        sbc.read( buffer );
View Full Code Here

        sbc.write( ByteBuffer.wrap( "CONTENT\n?!".getBytes() ) );

        assertEquals( 10L, sbc.position() );
        assertEquals( 10L, sbc.size() );

        sbc.position( 1L );
        ByteBuffer buffer = ByteBuffer.allocate( 8 );
        sbc.read( buffer );
        assertEquals( "ONTENT\n?", new String( buffer.array() ) );

        assertEquals( 9L, sbc.position() );
View Full Code Here

        sbc.position( 1L );
        ByteBuffer buffer = ByteBuffer.allocate( 8 );
        sbc.read( buffer );
        assertEquals( "ONTENT\n?", new String( buffer.array() ) );

        assertEquals( 9L, sbc.position() );

        sbc.position( 0L );
        sbc.truncate( 2L );
        ByteBuffer buffer3 = ByteBuffer.allocate( 2 );
        sbc.read( buffer3 );
View Full Code Here

        sbc.read( buffer );
        assertEquals( "ONTENT\n?", new String( buffer.array() ) );

        assertEquals( 9L, sbc.position() );

        sbc.position( 0L );
        sbc.truncate( 2L );
        ByteBuffer buffer3 = ByteBuffer.allocate( 2 );
        sbc.read( buffer3 );
        assertEquals( "CO", new String( buffer3.array() ) );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.