public static void writeFully(FileChannel file, long offset, ByteBuffer buffer) throws IOException {
        int write = 0;
        int size = buffer.remaining();
        while (write < size) {
            write += file.write(buffer, offset + write);
        }
        assert !buffer.hasRemaining();
    }
Slow function, should only used in test. Unless, you choose to optimize it.
This function will not move the position of <i>from</i>.
indexr-common/src/main/java/io/indexr/util/IOUtil.java