I’m working on a project where I have a hashmap with the key as a File object in Java IO library and a custom model object, called a DrawingModel as the value in the hashmap. When I change the model, I need to save the file. When I go through the following sequence of events:
- I open a File
- I do some changes
- I save that file (File -> Save)
- I Exit the file
- I then Open that same file
- However, it does not open!
My question is if I change the file (by saving) do I need to remove that key value pair from the Hashmap and add a new key value pair? Such that the value is the same but the keys are updated?
Thank you very much for your time and help!
Sincerely,
nc5
I suggest you put the file Name as the Key instead of the File Object and handle the file editing/updating stuff through another logic. A file object as key doesn’t make much sense.