Java ByteBuffer Write writeFully(FileChannel channel, ByteBuffer src)

Here you can find the source of writeFully(FileChannel channel, ByteBuffer src)

Description

Fully write to the file.

License

Mozilla Public License

Parameter

Parameter Description
channel the file channel
src the byte buffer

Declaration

public static void writeFully(FileChannel channel, ByteBuffer src) throws IOException 

Method Source Code

//package com.java2s;
/*//from w ww.  j  a  v a  2s.c  o m
 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
 * and the EPL 1.0 (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */

import java.io.IOException;

import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class Main {
    /**
     * Fully write to the file. This will write all remaining bytes.
     *
     * @param channel the file channel
     * @param src the byte buffer
     */
    public static void writeFully(FileChannel channel, ByteBuffer src) throws IOException {
        do {
            channel.write(src);
        } while (src.remaining() > 0);
    }
}

Related

  1. writeFromBuffer(SocketChannel channel, ByteBuffer buf, int sleepMsecs)
  2. writeFully(@Nonnull final FileChannel dst, @Nonnull final ByteBuffer src, @Nonnegative final long position)
  3. writeFully(ByteBuffer buf, WritableByteChannel out)
  4. writeFully(ByteBuffer buffer, WritableByteChannel channel)
  5. writeFully(FileChannel channel, ByteBuffer fileInfosBuffer)
  6. writeFully(FileChannel channel, long offset, ByteBuffer buf)
  7. writeFully(FileChannel fc, ByteBuffer buf, long offset)
  8. writeFully(FileChannel fileChannel, long filePosition, ByteBuffer buffer)
  9. writeFully(final FileChannel channel, final ByteBuffer dst, final long position)