Reputation: 41
I will explain it as easy as I can.
I've got a program that is doing backup of a files after that starting external java "program2" that is validating if the files are there.
"Program2" don't see any files (because folder was renamed)so he create a new files. What I want to do is to kill the program when it's done and edit the files.
My question is - What would be the best option to do so? I've got two ideas but not sure if any of them would work:
My program will count how many files were before the backup and after the start of "program2" will be checking if if the count before and after match.
Check if the files are used by "program2" and after they are free start editing the files.
Sorry for the long post. If you think there is better option please share. Thanks!
Upvotes: 0
Views: 47
Reputation: 4122
It would be more simple to count the number of files.
To do so, you can use .listFiles()
:
File folder;//I'll assume you initialize it somehow
int fileCount = 0;
if(folder.isDirectory()){//check if folder is actually a folder
fileCount = folder.listFiles().length;
}
where folder
is the directory to which you back up.
After doing so, you can simply compare the two numbers, one from before the backup and one after it is done.
Upvotes: 2