Java ReadableByteChannel Read read(ReadableByteChannel channel, ByteBuffer buffer)

Here you can find the source of read(ReadableByteChannel channel, ByteBuffer buffer)

Description

read

License

Apache License

Declaration

public static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;

public class Main {
    public static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException {
        int rem = buffer.position();
        while (channel.read(buffer) != -1 && buffer.hasRemaining()) {
        }//from   ww  w . ja  v  a 2 s. c  om
        return buffer.position() - rem;
    }
}

Related

  1. copyChannels(ReadableByteChannel input, WritableByteChannel output, int bufferSize)
  2. fill(ReadableByteChannel in, ByteBuffer buffer)
  3. getNextVIntAsLong(ByteBuffer buffer, ReadableByteChannel readChannel)
  4. infiniteReadableByteChannelFor(ByteBuffer... buffers)
  5. read(ReadableByteChannel channel, ByteBuffer buffer)
  6. read(ReadableByteChannel channel, ByteBuffer[] dsts)
  7. read(ReadableByteChannel channel, ByteBuffer[] dsts, int offset, int length)
  8. read(ReadableByteChannel channel, int amount, ByteBuffer dest)
  9. readAll(ReadableByteChannel ch, ByteBuffer dst)