@Test public void getBuffer() throws IOException { ByteBuffer buffer = memoryMappedFile.getBuffer(100); assertNotNull(buffer); assertEquals(100, buffer.remaining()); }
@Override public ByteBuffer getBuffer(int size) throws IOException { if (raf == null) { raf = new RandomAccessFile(file, "rw"); } return raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); }
MemoryMappedFileImpl implements MemoryMappedFile { @Override public ByteBuffer getBuffer(int size) throws IOException { if (raf == null) { raf = new RandomAccessFile(file, "rw"); } return raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); } }
MemoryMappedFileImpl implements MemoryMappedFile { @Override public ByteBuffer getBuffer(int size) throws IOException { if (raf == null) { raf = new RandomAccessFile(file, "rw"); } return raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); } MemoryMappedFileImpl(File file); }
MemoryMappedFileImpl implements MemoryMappedFile { @Override public ByteBuffer getBuffer(int size) throws IOException { if (raf == null) { raf = new RandomAccessFile(file, "rw"); } return raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); } MemoryMappedFileImpl(File file); @Override boolean exists(); @Override ByteBuffer getBuffer(int size); @Override void close(); }
MemoryMappedFileImpl implements MemoryMappedFile { @Override public ByteBuffer getBuffer(int size) throws IOException { if (raf == null) { raf = new RandomAccessFile(file, "rw"); } return raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, size); } MemoryMappedFileImpl(File file); @Override boolean exists(); @Override ByteBuffer getBuffer(int size); @Override void close();  }