Here you can find the source of read(ReadableByteChannel channel, ByteBuffer buffer)
Parameter | Description |
---|---|
channel | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException
//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; } }