Skip to Content
Functional Programming in Java
book

Functional Programming in Java

by Venkat Subramaniam
February 2014
Intermediate to advanced
160 pages
4h 59m
English
Pragmatic Bookshelf
Content preview from Functional Programming in Java

Watching a File Change

We know how to look for files and directories, but if we want to sit back and get alerts when a file is created, modified, or deleted, that’s quite easy as well. Such a facility is useful for monitoring changes to special files like configuration files and system resources. Here we’ll explore the facility that’s been available since Java 7, the WatchService, to watch for file changes. Most of the features we’ll see here are from JDK 7 and the main improvement will be in the convenience of the internal iterator.

Let’s create an example to watch for file changes in the current directory. The Path class in the JDK can lead to an instance of the file system, which acts as a factory for the watch service. We can register with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in Java

Functional Programming in Java

Pierre-Yves Saumont

Publisher Resources

ISBN: 9781941222690Errata Page