public static void writeFully(FSDataOutputStream ouput, ByteBuffer buffer) throws IOException {
        byte[] bytes = new byte[2048];
        int count = 0;
        int size = buffer.remaining();
        while (count < size) {
            int step = Math.min(2048, size - count);
            count += step;
            buffer.get(bytes, 0, step);
            ouput.write(bytes, 0, step);
        }
        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