Reputation: 1932
I want to sync a folder like Dropbox. If in my Folder is changed a file or a folder, I want to get an Event, which starts my synchronisation Class. How can I get such an Event without scanning this folder by an Intervall?
Upvotes: 0
Views: 301
Reputation: 34323
You have at least two options. You can either reinvent the wheel as Arpit suggested or you can also use the WatchService API.
You can find a WatchService tutorial here.
Upvotes: 1
Reputation: 12797
Some start for you:
get the list of all files : yourdir.listFiles()
now for each file in filelist:
file.getLastModified()
if it is equal to current time or differ from lastSynctime
(you need to maintain it in your sync class) then sync it.
Upvotes: 0