Open FaliciaOng opened 2 years ago
The new File()
in the code snippet is only creating the file object to handle the file fruits.txt
in the data
folder.
See the explanation just above the code snippet
I could only make it work after calling f.getParentFile().mkdirs() and then f.createNewFile(). Is this way of creating the file acceptable?
If your intention is to create a file programmatically, this is one way to do it, and acceptable.
Thank you for the clarification, for week 6 IP, I would like to confirm with you that we are expected to create the file at startup, save the contents when updated, load to file the when programs run again and handle 2 exceptions(when the file does not exist and when a folder does not exist)?
👆 is this what you are asking? If so, yes
When creating the file, do we have to manually create the file "data"? I tried to run the code given in the textbook but i was not able to generate the data.txt file. After some googling, I could only make it work after calling f.getParentFile().mkdirs() and then f.createNewFile(). Is this way of creating the file acceptable?