I am using the following to go through a dat file and I am hoping to replace money with another double value.
try {
RandomAccessFile file = new RandomAccessFile("files/bank.dat","r");
FileChannel poos;
for(int pos = 0; pos < 1000; pos++) {
file.seek(40*pos);
file.seek(40*pos + 25);
file.seek(40*pos + 30);
double money = file.readDouble(); //I WANT TO CHANGE THIS VALUE!
poos = file.getChannel();
if(pos == num) {
long poss=poos.position();
money += i;
file.seek(poss);
System.out.println(money);
file.writeDouble(money);
}
}
file.close();
}
catch (IOException ex) { }
However it does not seem to be working properly - no errors but it doesn't seem to be replacing the text.
Edit:
What I am trying to do is go through the text and find a value, in this case money, which I am then going to replace with the modified value. This is what I am struggling with.