I have a file:
RandomAccessFile file = new RandomAccessFile("files/bank.txt", "r");
And I am reading and writing data to/from this file using:
for (int pos = 0; pos < 1000; pos++) {
file.seek(40 * pos + 30);
double money = file.readDouble();
if (pos == num) {
money += i;
System.out.println(money+" "+i);
file.seek(40 * pos + 30);
file.writeDouble(money);
}
}
In this way it reads the double - works correctly, and then it should overwrite that double with the value it held previously plus i
. However this is not working as the value doesn't change. What have I done wrong?