Hi,
I recently started learning Java and now am stuck with a problem I have not been able to figure out for nearly 3 weeks now.
The app:
When finished it shall be used to manage DVD Collections, saving the information in an XML file.
The status quo:
Reading the XML file into a special list model and this into a JTable works, selecting a specific dvd and loading the data into another JFrame also works.
The problem:
Adding a new dvd to the file does not work.
When using "append mode", the line is appended below the end tag of the XML file, thus rendering it invalid.
The question:
How do I insert a line into a (XML) file?
Reading the hole file into a byte array is no real option, since the file might get very big...
Copying the current file into a temporary file, inserting the new dvd a the correct position, deleting the original file and renaming the temp file to the original`s file name is also not a real option...
If anyone of you can give me a hint / tip / link or anything else that helps to figure out this problem, I would really appreciate it...
Thanks for your help in advance
I recently started learning Java and now am stuck with a problem I have not been able to figure out for nearly 3 weeks now.
The app:
When finished it shall be used to manage DVD Collections, saving the information in an XML file.
The status quo:
Reading the XML file into a special list model and this into a JTable works, selecting a specific dvd and loading the data into another JFrame also works.
The problem:
Adding a new dvd to the file does not work.
When using "append mode", the line is appended below the end tag of the XML file, thus rendering it invalid.
The question:
How do I insert a line into a (XML) file?
Reading the hole file into a byte array is no real option, since the file might get very big...
Copying the current file into a temporary file, inserting the new dvd a the correct position, deleting the original file and renaming the temp file to the original`s file name is also not a real option...
If anyone of you can give me a hint / tip / link or anything else that helps to figure out this problem, I would really appreciate it...
Thanks for your help in advance