private int read(ByteBuffer dst, long position) throws IOException {
        int bytesRead = 0;
        while (dst.hasRemaining()) {
            int read = randomAccessFile.read(dst, position + bytesRead);
            // kdio will throw an exception rather than return -1, so we don't need to check for -1
            bytesRead += read;
        }
        return bytesRead;
    }
Create the file and set length if not exists, and check the file size if exists.
s3stream/src/main/java/com/automq/stream/s3/wal/util/WALBlockDeviceChannel.java