Gridarta Editor
Static Public Member Functions | Package Functions | Static Package Functions | Private Member Functions | Private Attributes | List of all members
WatchDir Class Reference
Collaboration diagram for WatchDir:
Collaboration graph

Static Public Member Functions

static void main (String[] args) throws IOException
 

Package Functions

static< T > WatchEvent< T > cast (WatchEvent<?> event)
 
void processEvents ()
 
 WatchDir (Path dir, boolean recursive) throws IOException
 

Static Package Functions

static void usage ()
 

Private Member Functions

void register (Path dir) throws IOException
 
void registerAll (final Path start) throws IOException
 

Private Attributes

int count
 
final boolean recursive
 
boolean trace = false
 
final WatchService watcher
 

Detailed Description

Example to watch a directory (or tree) for changes to files.

Definition at line 51 of file WatchDir.java.

Constructor & Destructor Documentation

◆ WatchDir()

WatchDir.WatchDir ( Path  dir,
boolean  recursive 
) throws IOException
package

Creates a WatchService and registers the given directory

Definition at line 93 of file WatchDir.java.

References recursive, and registerAll().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ cast()

static<T> WatchEvent<T> WatchDir.cast ( WatchEvent<?>  event)
package

Definition at line 59 of file WatchDir.java.

Referenced by processEvents().

Here is the caller graph for this function:

◆ main()

static void WatchDir.main ( String[]  args) throws IOException
static

Definition at line 168 of file WatchDir.java.

References recursive, usage(), and WatchDir().

Here is the call graph for this function:

◆ processEvents()

void WatchDir.processEvents ( )
package

Process all events for keys queued to the watcher

Definition at line 112 of file WatchDir.java.

References cast(), count, name, recursive, registerAll(), and watcher.

Here is the call graph for this function:

◆ register()

void WatchDir.register ( Path  dir) throws IOException
private

Register the given directory with the WatchService

Definition at line 66 of file WatchDir.java.

References count, trace, and watcher.

◆ registerAll()

void WatchDir.registerAll ( final Path  start) throws IOException
private

Register the given directory, and all its sub-directories, with the WatchService.

Definition at line 77 of file WatchDir.java.

Referenced by processEvents(), and WatchDir().

Here is the caller graph for this function:

◆ usage()

static void WatchDir.usage ( )
staticpackage

Definition at line 163 of file WatchDir.java.

Referenced by main().

Here is the caller graph for this function:

Member Data Documentation

◆ count

int WatchDir.count
private

Definition at line 56 of file WatchDir.java.

Referenced by processEvents(), and register().

◆ recursive

final boolean WatchDir.recursive
private

Definition at line 54 of file WatchDir.java.

Referenced by main(), processEvents(), and WatchDir().

◆ trace

boolean WatchDir.trace = false
private

Definition at line 55 of file WatchDir.java.

Referenced by register().

◆ watcher

final WatchService WatchDir.watcher
private

Definition at line 53 of file WatchDir.java.

Referenced by processEvents(), and register().


The documentation for this class was generated from the following file: