BufferOverflowException problem
I am using MappedByteBuffer. This code cause this annoying exception:
Code:
import java.io.*;
import java.util.*;
import java.nio.channels.*;
import java.nio.*;
class Lab3d
{
public static void main(String[] args) throws Exception
{
long start;
long end;
RandomAccessFile fio = new RandomAccessFile ("C:\\temp2.txt", "rw");
FileChannel fc = fio.getChannel ();
MappedByteBuffer buffer = fc.map (FileChannel.MapMode.READ_WRITE, 0, (int) fc.size ());
start = System.currentTimeMillis ();
buffer.putInt (10);
fio.close ();
end = System.currentTimeMillis ();
}
}