public static void writeFully(FileChannel file, ByteBuffer buffer) throws IOException {
        while (buffer.hasRemaining()) {
            int rt = file.write(buffer);
            if (rt < 0) {
                throw new IOException("Failed to write");
            }
        }
    }
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