user2332505
user2332505

Reputation: 649

File Change Detector In Java ( 95% implemented but require help in one case)

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

  1. Name of the files that have been deleted since last run
  2. New files created since last run
  3. Files whose size have grown more than x% and
  4. Files whose size have reduced more than x%.

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

Answers (1)

Devolus
Devolus

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

Related Questions