Reputation: 649
My Project is : File Change Detector: The input to the application will be a group of directories and files. When the application runs for the first time it will simply summarize the names and sizes of the files. On subsequent runs it should report
I have implemented a java program which scans user selected folder via JFileChooser
and performs all functionality .
But the problem is, if a user creates two files with same name in different subfolder of "SELECTED" main problem , it leads to ambiguous condition and hence project fails.
How to Differentiate Two Files ie one in C:\Main\SubFolder1\a.txt
and C:\Main\SubFolder2\a.txt
....(Both have same size and created on same time)
Upvotes: 2
Views: 127
Reputation: 22094
Store the path of the file as well. After all, you just realized that two files with the same name can exist in different directories being different files.
Either that, or if you really want to disregard the directory, then you should enumerate them if you encounter more than one entry with the same name.
The Filechooser returns the full path:
String Path = chooser.getSelectedFile().toString();
Upvotes: 4