Here you can find the source of writeFully(ByteBuffer buffer, WritableByteChannel channel)
Parameter | Description |
---|---|
buffer | the data to be written |
channel | the channel to which we want to write data |
Parameter | Description |
---|---|
IOException | if there is a problem writing to the channel |
public static void writeFully(ByteBuffer buffer, WritableByteChannel channel) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.WritableByteChannel; public class Main { /**/* w ww . ja v a2s . com*/ * Writes the entire remaining contents of the buffer to the channel. May complete in one operation, but the * documentation is vague, so this keeps going until we are sure. * * @param buffer the data to be written * @param channel the channel to which we want to write data * * @throws IOException if there is a problem writing to the channel */ public static void writeFully(ByteBuffer buffer, WritableByteChannel channel) throws IOException { while (buffer.hasRemaining()) { channel.write(buffer); } } }