FileChannel.MapMode.READ_WRITE
FileChannel.MapMode.READ_WRITE defines the mode for a read/write mapping.
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.IntBuffer;
import java.nio.channels.FileChannel;
public class Main {
public static void main(String[] args) throws IOException {
FileChannel fc = new RandomAccessFile(new File("temp.tmp"), "rw").getChannel();
IntBuffer ib = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size()).asIntBuffer();
ib.put(0);
for (int i = 1; i < 10; i++)
ib.put(ib.get(i - 1));
fc.close();
}
}
Home
Java Book
File Stream
Java Book
File Stream
FileChannel:
- FileChannel
- FileChannel.MapMode.READ_WRITE
- FileChannel: close()
- FileChannel: lock(long position, long size, boolean shared)
- FileChannel: map(MapMode mode, long position, long size)
- FileChannel: position()
- FileChannel: position(long newPosition)
- FileChannel: read(ByteBuffer dst)
- FileChannel: size()
- FileChannel: transferFrom(ReadableByteChannel src, long position, long count)
- FileChannel: transferTo(long position, long count, WritableByteChannel target)
- FileChannel: tryLock()
- FileChannel: write(MappedByteBuffer buffer)