• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification about WatchService function for ENTRY_MODIFY

 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
Could someone please try the following code out?



Just copying and paste the code in a file called Tries.java it works, the only thing to change is the path of the folder to be registered. (See LINE 9 in the code)
In theory ENTRY_MODIFY should be triggered each time a file or a folder in the registered folder gets modified.
In practice (at least to me using Ubuntu 12.10), the event StandardWatchEventKinds.ENTRY_MODIFY does get triggered if I modify a file (say adding "hello" to a txt for example), but does not trigger if a file is added in a subfolder of the registered folder (Desktop in my case), ie adding a file in Desktop/subfolder/ does not trigger ENTRY_MODIFY.
It should as the API say:


ENTRY_MODIFY

public static final WatchEvent.Kind<Path> ENTRY_MODIFY

Directory entry modified.

When a directory is registered for this event then the WatchKey is queued when it is observed that an entry in the directory has been modified. The event count for this event is 1 or greater.


I asking any of you (if you have time) to copy and paste the code and check wheter or not ENTRY_MODIFY gets triggered by adding a file or deleting one in a subdirectory of the registered directory.

Maybe it's just me using Ubuntu and with Windows it will trigger as it should.

Thanks in advance.
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Saloon keepers
Could you please move this post to Java in General ? I posted it here as Watch a Directory for change is an exam topic.
However I haven't got any response yet, maybe in Java in General is more appropriate though.
I am asking just to copy and paste the code to see whether or not when adding or removing a file in a subdirectory of the directory being registered, will trigger an MODIFY_ENTRY.
Of course after having copied and pasted the code the Desktop's path must be adapted to yours.
Thanks in advance.
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will trigger when you create ,delete or rename.
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meeta gaur wrote:It will trigger when you create ,delete or rename.


What is going to be triggered?

I have /home/user/Desktop which is registered
and /home/user/Desktop/subFolder which is not but it is a subfolder (an item) of Desktop which is registered.
As far as the API goes it should trigger ENTRY_MODIFY in 2 cases:
A file is modified innerly( for example adding some text to an already existing "Desktop/Test.txt")
A subDirectory is modified innerly (for example adding or removing a file within the subfolder)
Now I have already asked a question on stackoverflow about the same.
http://stackoverflow.com/questions/18574646/standardwatchevents-entry-modify-triggers-with-modifying-a-subfolder
and an user using Windows replied that it actually triggers when adding or removing a file in a subFolder. I would like to confirm it with others too.
What I am asking is: Could you please try to see if the event ENTRY_MODIFY gets triggered if a file is added in any of the subfolder of the registered folder (Desktop in the above case).
Personally using ubuntu it does not trigger for me, whereas for the user in the above stackoverflow link said it does (he uses Windows).
Thanks in advance.
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to move this thread to "Java in General"?

Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic