Here you can find the source of writeFully(FileChannel channel, ByteBuffer src)
Parameter | Description |
---|---|
channel | the file channel |
src | the byte buffer |
public static void writeFully(FileChannel channel, ByteBuffer src) throws IOException
//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); } }