package com.github.musikk.hex;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

public class FileDataProvider implements DataProvider {

	private final RandomAccessFile file;
	private final long fileLength;

	public FileDataProvider(File file) throws IOException {
		this.file = new RandomAccessFile(file, "r");
		this.fileLength = file.length();
	}

	@Override
	public long getLength() {
		return fileLength;
	}

	@Override
	public int get(byte[] data, long offset) {
		try {
			file.seek(offset);
			return file.read(data);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

}

@@ -531,33 +531,269 @@
 t);%0A
+%0A
 %09%09%09
-return file.read(data)
+int read = 0;%0A%09%09%09while (read %3C data.length) %7B%0A%09%09%09%09byte%5B%5D buf = new byte%5BMath.min(2048, data.length - read)%5D;%0A%09%09%09%09int r = file.read(buf);%0A%09%09%09%09if (r %3C 0) %7B%0A%09%09%09%09%09return read;%0A%09%09%09%09%7D%0A%09%09%09%09System.arraycopy(buf, 0, data, read, r);%0A%09%09%09%09read += r;%0A%09%09%09%7D%0A%09%09%09return read
 ;%0A%09%09

add buffer support to FileDataProvider