WatchService

A service that will monitor the file system for file creation, deletion and modification.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def close(): Unit

Closes this WatchService.

Closes this WatchService.

def init(): Unit

Initializes the watchservice.

Initializes the watchservice.

def poll(timeout: Duration): WatchKey

Retrieves the next WatchKey that has a WatchEvent waiting. Waits until the timeout is expired is no such key exists.

Retrieves the next WatchKey that has a WatchEvent waiting. Waits until the timeout is expired is no such key exists.

Value Params
timeout

Maximum time to wait

Returns

The next WatchKey that received an event, or null if no such key exists.

def pollEvents(): Map[WatchKey, Seq[WatchEvent[Path]]]

Retrieves all the events and groups them by watch key. Does not wait if no event is available.

Retrieves all the events and groups them by watch key. Does not wait if no event is available.

Returns

The pending events.

def register(path: Path, events: Kind[Path]*): WatchKey

Registers a path to be monitored.

Registers a path to be monitored.

Value Params
events

The events that should be registered.

path

The path to monitor.

Returns

A WatchKey, that represents a token of registration.