Question about OCJP 7 (804) related to WatchDirectory
Posted: Thu May 16, 2013 9:37 am
So basically for the following code related to topic "Watching directory":
I have 2 questions:
1) What should happen to a directory to actually queue the events? how many file should be deleted together to make the method queue and return a real list instead of a single element?
2) How can we trigger the "ENTRY_MODIFY" case? I tried personally to modify the file name of a directory on my desktop and it gave me back a "previous file has been deleted" plus "renamed file has been created". What do they mean with ENTRY_MODIFY?I also tried to modified the file content and nothing.It still triggers first ENTRY_DELETE and then ENTRY_CREATE. How is it possible to trigger ENTRY_MODIFY?
Thanks in advance.
The_Nick.
Code: Select all
for(WatchEvent<?> event:kC.pollEvents()){
switch(event.kind().name()){
case "OVERFLOW":
System.out.println("We lost some events");
break;
case "ENTRY_CREATE":
System.out.println("File " + event.context() + " has been modified!");
break;
case "ENTRY_MODIFY":
System.out.println("File" + event.context()+ "has been modified!");
case "ENTRY_DELETE":
System.out.println("File" + event.context()+ "has been deleted!");
1) What should happen to a directory to actually queue the events? how many file should be deleted together to make the method queue and return a real list instead of a single element?
2) How can we trigger the "ENTRY_MODIFY" case? I tried personally to modify the file name of a directory on my desktop and it gave me back a "previous file has been deleted" plus "renamed file has been created". What do they mean with ENTRY_MODIFY?I also tried to modified the file content and nothing.It still triggers first ENTRY_DELETE and then ENTRY_CREATE. How is it possible to trigger ENTRY_MODIFY?
Thanks in advance.
The_Nick.