Hi,
At the moment my program holds a list video titles in a doubly linked list. When the user wants to save the list to file it is converted to an array then saved onto file.
But the problem starts when i want to delete from the list. Say for example there are two video titles in the linked list:
"Finding Nemo
Scarface."
if the user deletes the first video ie Finding Nemo, it will be correctly done in the linked list and also saved correctly on to file as:
"Scarface"
Then the user will close the program (and also the file). However, when they open it the contents on the file will be shown as:
"Scarface
Scarface".
I know it must be my file handling (and/or reading from file) that is dodgy but i can't understand why.
I am using RAF for handling the file and what *should* happen when i save to file is:
before saving anything to file, the file (called vidfile) is deleted.
then the file pointer is set back to the first position in the file and then it writes the array, videoarray, to vidfile.
Below is what my code looks like:
------------------------------------------------------------
RandomAccessFile raf = new RandomAccessFile(vidfile, "rw");
vidfile.delete();
raf.seek(0);
for(int x=0; x<videoarray.length; x++){
videotitle=videoarray[x];
raf.writeBytes(videotitle);
System.out.println("This Video is now on file:\n"+ videotitle+"\n");
}
----------------------------------------------------
Can anyone help please?
Regards,
Nikki