Examples of SeekableByteChannel


Examples of org.uberfire.java.nio.channels.SeekableByteChannel

        Files.newOutputStream( null );
    }

    @Test
    public void newByteChannel() throws IOException {
        final SeekableByteChannel sbc = Files.newByteChannel( newTempDir().resolve( "file.temp.txt" ), new HashSet<OpenOption>() );
        assertThat( sbc ).isNotNull();
        sbc.close();

        final SeekableByteChannel sbc2 = Files.newByteChannel( newTempDir().resolve( "file.temp2.txt" ) );
        assertThat( sbc ).isNotNull();
        sbc.close();
    }
View Full Code Here

Examples of org.uberfire.java.nio.channels.SeekableByteChannel

    private void copyFile( final JGitPathImpl source,
                           final JGitPathImpl target,
                           final CopyOption... options ) {

        final InputStream in = newInputStream( source, convert( options ) );
        final SeekableByteChannel out = newByteChannel( target, new HashSet<OpenOption>() {{
            add( StandardOpenOption.TRUNCATE_EXISTING );
            for ( final CopyOption _option : options ) {
                if ( _option instanceof OpenOption ) {
                    add( (OpenOption) _option );
                }
            }
        }} );

        try {
            int count;
            byte[] buffer = new byte[ 8192 ];
            while ( ( count = in.read( buffer ) ) > 0 ) {
                out.write( ByteBuffer.wrap( buffer, 0, count ) );
            }
        } catch ( Exception e ) {
            throw new IOException( e );
        } finally {
            try {
                out.close();
            } catch ( java.io.IOException e ) {
                throw new IOException( e );
            } finally {
                try {
                    in.close();
View Full Code Here

Examples of org.uberfire.java.nio.channels.SeekableByteChannel

        assertFalse( ioService().exists( file ) );
        String content = "sample content";
        ioService.write( file, content );
        assertTrue( ioService().exists( file ) );

        final SeekableByteChannel sbc = ioService().newByteChannel( file, StandardOpenOption.READ );
        String readContent = readSbc( sbc );

        assertEquals( content, readContent );

        ioService().delete( file );
View Full Code Here

Examples of org.uberfire.java.nio.channels.SeekableByteChannel

        ioService().deleteIfExists( file );

        assertFalse( ioService().exists( file ) );

        final SeekableByteChannel sbc = ioService().newByteChannel( file, Collections.<OpenOption>emptySet(), new FileAttribute<Object>() {
            @Override
            public String name() {
                return "custom";
            }

            @Override
            public Object value() {
                return dateValue;
            }
        } );

        sbc.write( ByteBuffer.wrap( "helloWorld!".getBytes() ) );
        sbc.close();

        assertTrue( ioService().exists( file ) );

        Map<String, Object> attrs = ioService().readAttributes( file );
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.