Java Directory Events

Source: Internet
Author: User

When an object in the file system is modified, we can listen watch to the service to get an alert. The java.nio.file following classes and interfaces in the package provide watch services.

    • Watchable interface

    • Watchservice interface

    • Watchkey interface

    • Watchevent interface

    • Watchevent.kind interface

    • Standardwatcheventkinds class

Watchableobject represents a file system object that can be monitored. Watchableobjects can be watch registered with the service.
PathObject is an Watchable object.

WatchServiceRepresents the observation service. When an object uses WatchService registration, it WatchService returns a WatchKey token that is registered. WatchEventrepresents an event on an object that is registered to the monitoring service. Its kind() method returns the type of event that occurred.
Its context() method returns an Path object that represents the entry in which the event occurred. count()method returns the number of times an event occurred for a specific notification. If it returns a value greater than 1 , then it is a repeating event.

WatchEvent.Kind <T>Represents the type of event that occurred. StandardWatchEventKindsclass defines the constants used to represent the kind of event, as shown below.

Click on the link to view the details

Java Directory Events

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.