"Before adding a new line, re-write all of its contents to the file."
Are we supposed to write the file, add the new product to whatever data structure we have and then write the file again with the new data?
BlueJavaBanana
Level 37
Can anyone clarify what this bit means?
Resolved
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
BlueJavaBanana
26 May 2020, 15:52
Thank you all!
+1
Seb
26 May 2020, 15:50
Hi BJB. :-)
It basically means that we're supposed to read in the given file in step 1.
That way we can find out the maximum id.
In step 2 you can then write the content of the file, that you just read in in order to find out the maximum id, to the file again.
In step 3 add the line with the new product info.
And finally you can now close the stream and you're done.
Enjoy. ;-)
Seb
P.S.: Or in short as Guadalupe points out - it just means that you cannot append to the file, but you have to rewrite it instead. :-)
+2
Guadalupe Gagnon
26 May 2020, 15:47
Just means that your file writer should not append.
+3
Seb
26 May 2020, 15:52
:-)
+1