What does it mean to "repeat" the event?

Reading javadocs for WatchEvent, I see that the method count()allows you to find out if an event is repeated by its result.

Returns the number of events. If the number of events is greater than 1, this is a repeating event.

What does it mean? Does this mean that two or more objects WatchEventbelong to the same โ€œeventโ€ (for example, a file being created)?

I am experimenting with an Oracle site for a new API WatchService, and this part confused me, especially since I will receive a different number of events for successive runs of the same test code (in which I write to a file using FileWriterwithout interacting with it manually), but the result count()does not exceed 1.

Edit: I understand that this may be related to this other question about repeated events , but this does not answer what the event actually means.

+4
source share
2 answers

I spent some time experimenting with this, and this is my conclusion:

An event is repeated for the file fand event type eif fseveral type events have occurred in the same file e.

If an event of the type eoccurred with several files f1, f2and f3, but only once each, then none of these events are repeated.

.take() a WatchKey WatchService, WatchEvent , , , . .count() 1, WatchKey WatchService.

, A.txt , :

  • B.txt .
  • B.txt .
  • A.txt .
  • B.txt .
  • A.txt .

WatchEvents:

  • create B.txt.
  • B.txt.
  • A.txt. .count() 2.
  • delete B.txt.

, 3*n WatchKey, n - , .

, StandardWatchEventKinds, OVERFLOW , , .

+2

. , , , .

, , .

0

All Articles