import java.io.IOException; import java.io.RandomAccessFile; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; public class MemoryMappedFile { private String deviceName; // initialise to peripheral name private String filename; // initialise to peripheral buffer file name public MemoryMappedFile (String deviceName, String filename) { if (deviceName != null) this.setDeviceName(deviceName); else this.setDeviceName(""); if (filename != null) this.filename = filename; else this.filename = "largeFile.txt"; } public int write (int position, int size, Byte[] bytesBuffer) { int count = 0; RandomAccessFile memoryMappedFile; try { memoryMappedFile = new RandomAccessFile(this.filename, "rw"); //Mapping a file into memory MappedByteBuffer out = memoryMappedFile.getChannel().map(FileChannel.MapMode.READ_WRITE, position, size); //Writing into Memory Mapped File for (int i = 0; i < size; i++) { if (i