Java 8 ScatteringByteChannel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ScatteringByteChannel class.

This code example shows how to use the following methods:read
 
	protected boolean readFrom(ScatteringByteChannel scatteringByteChannel)
		throws IOException {
 
		if (_headerByteBuffer.hasRemaining()) {
			if (scatteringByteChannel.read(_headerByteBuffer) == -1) {
				throw new EOFException();
			} 
 
			if (_headerByteBuffer.hasRemaining()) {
				return false; 
			} 
 
			int dataSize = BigEndianCodec.getInt(
				_headerBufferArray, _INDEX_DATA_SIZE);
 
			if (dataSize == 0) {
				_dataByteBuffer = _EMPTY_BUFFER;
 
				return true; 

5
CodeRank
This code example shows how to use the following methods:read
	@Override 
	public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
		ByteBuffer buffer = ByteBuffer.allocate(length);
		WritableByteChannel channel = Channels.newChannel(output);
		 
		int count = in.read(buffer);
		channel.write(buffer);
		return count;
	} 
 
	@Override 
	public ByteBuf copy(int index, int length) {
		throw new UnsupportedOperationException("Cannot seek in input stream.");
	} 
 
	@Override 
	public int nioBufferCount() { 
		return 0; 
	} 
 
4
CodeRank
This code example shows how to use the following methods:read
        } 
 
        @Override 
        public void run() { 
            try { 
                readResult = channel.read(buffer);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } 
        } 
 
        public int getReadResult() { 
            return readResult;
        } 
 
        public ByteBuffer getReadBuffer() {
            return buffer;
        } 
    } 
 
4
CodeRank
This code example shows how to use the following methods:read
This code example shows how to use the following methods:read
    public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
        ensureAccessible(); 
        ByteBuffer tmpBuf = internalNioBuffer();
        tmpBuf.clear().position(index).limit(index + length);
        try { 
            return in.read(tmpNioBuf);
        } catch (ClosedChannelException e) {
            return -1; 
        } 
    } 
 
    @Override 
    public int nioBufferCount() { 
        return 1; 
    } 
 
    @Override 
    public ByteBuffer[] nioBuffers(int index, int length) {
        return new ByteBuffer[] { nioBuffer(index, length) };
    } 
3
CodeRank
This code example shows how to use the following methods:read
    public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
        ensureAccessible(); 
        ByteBuffer tmpBuf = internalNioBuffer();
        tmpBuf.clear().position(index).limit(index + length);
        try { 
            return in.read(tmpBuf);
        } catch (ClosedChannelException e) {
            return -1; 
        } 
    } 
 
    @Override 
    public int nioBufferCount() { 
        return 1; 
    } 
 
    @Override 
    public ByteBuffer[] nioBuffers(int index, int length) {
        return new ByteBuffer[] { nioBuffer(index, length) };
    } 
3
CodeRank
See Code Examples for Java 8 ScatteringByteChannel Methods: