List of utility methods to do ByteBuffer Write
int | writeFully(@Nonnull final FileChannel dst, @Nonnull final ByteBuffer src, @Nonnegative final long position) write Fully int count = 0; while (src.remaining() > 0) { count += dst.write(src, position + src.position()); return count; |
void | writeFully(ByteBuffer buf, WritableByteChannel out) if we were to register for OP_WRITE and send the remaining data on readyOps for this channel we have to either block the caller thread or queue the message buffers that may arrive while waiting for OP_WRITE. int written = 0; int toWrite = buf.limit(); while (written < toWrite) { written += out.write(buf); |
void | writeFully(ByteBuffer buffer, WritableByteChannel channel) Writes the entire remaining contents of the buffer to the channel. while (buffer.hasRemaining()) {
channel.write(buffer);
|
void | writeFully(FileChannel channel, ByteBuffer fileInfosBuffer) write Fully while (fileInfosBuffer.hasRemaining()) {
channel.write(fileInfosBuffer);
|
void | writeFully(FileChannel channel, ByteBuffer src) Fully write to the file. do { channel.write(src); } while (src.remaining() > 0); |
void | writeFully(FileChannel channel, long offset, ByteBuffer buf) write Fully int remaining = buf.limit() - buf.position(); while (remaining > 0) { int written = channel.write(buf, offset); if (written < 0) throw new EOFException(); remaining -= written; |
void | writeFully(FileChannel fc, ByteBuffer buf, long offset) Write a ByteBuffer to a FileChannel at a given offset, handling short writes. do { offset += fc.write(buf, offset); } while (buf.remaining() > 0); |
void | writeFully(FileChannel fileChannel, long filePosition, ByteBuffer buffer) write Fully int startBufferPosition = buffer.position(); while (buffer.remaining() > 0) { fileChannel.write(buffer, filePosition + buffer.position() - startBufferPosition); |
void | writeFully(final FileChannel channel, final ByteBuffer dst, final long position) write Fully while (dst.remaining() > 0) {
channel.write(dst, position + dst.position());
|
void | writeFully(final WritableByteChannel channel, final ByteBuffer buf) write Fully do { int written = channel.write(buf); if (written < 0) { throw new EOFException(); } while (buf.hasRemaining()); |