Java ReadableByteChannel Read read(ReadableByteChannel channel, ByteBuffer buffer)

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

Description

read

License

Open Source License

Parameter

Parameter Description
channel a parameter

Exception

Parameter Description
IOException an exception

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.nio.ByteBuffer;

import java.nio.channels.ReadableByteChannel;

public class Main {
    /**/*ww  w.j  a v  a  2 s.  c om*/
     * @param channel
     * @return
     * @throws IOException
     */
    public static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException {
        int count = channel.read(buffer);
        if (count == -1)
            throw new EOFException("Received -1 when reading from channel, socket has likely been closed.");
        return count;
    }
}

Related

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