Abstract
The Watch Service API was introduced in Java 7 (NIO.2) as a thread-safe service that is capable of watching objects for changes and events. The most common use is to monitor a directory for changes to its content through actions such as create, delete, and modify. You’ve probably seen the effect of such a service many times. For example, when you open a text file in an editor (such as GridinSoft Notepad, jEdit, etc.) and the file content is modified outside the editor, you will see a message that asks whether you want to reload the file because it was modified. This means the editor has detected a file change through a watch service and is reporting it accordingly. This is known as the file change notification mechanism, and starting with NIO.2, it is available through the Watch Service API.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2011 Anghel Leonard
About this chapter
Cite this chapter
Leonard, A. (2011). Watch Service API. In: Pro Java 7 NIO.2. Apress. https://doi.org/10.1007/978-1-4302-4012-9_6
Download citation
DOI: https://doi.org/10.1007/978-1-4302-4012-9_6
Publisher Name: Apress
Print ISBN: 978-1-4302-4011-2
Online ISBN: 978-1-4302-4012-9
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)