# Class: com.pnfsoftware.jeb.util.io.FileMonitor

File monitors can be used to create and retrieve lock on a file for exclusive operations. Locks are implemented as small files alongside the file to be locked.

## Static Field: CHECK_MS
Type: `long`

Constant value: `3000`
Description: Check frequency in ms, that is, the frequency at which a lock\-file write\-timestamp is verified.

## Static Field: TOUCH_MS
Type: `long`

Constant value: `1000`
Description: Touch frequency in ms, that is, the frequency at which a lock\-file write\-timestamp is updated.

## Method: isLocked
- return type: `boolean`

Description: Determine whether a valid lock file exists.
return: true if a valid lock file \(per this monitor settings\) exists and is recent enough to         be valid

## Method: lock

Description: Attempt to create and refresh a valid lock file \(per this monitor setting\). This call should be mirrored by a call to [#unlock(boolean)](#unlock(boolean)) when monitoring is to stop. This method does not hard fail if the lock file cannot be created \(e.g. attempting to create a lock on a read\-only partition\).

## Method: unlock
- parameter: `unregister`, type: `boolean`

Description: Stop refreshing the lock file.
parameter: unregister: true to remove this monitor from the monitor registry
throws: if interrupted while waiting for the monitor thread to stop

## Static Method: create
- parameter: `file`, type: `java.io.File`
- return type: `com.pnfsoftware.jeb.util.io.FileMonitor`

Description: Create a monitor object for the provided file. \(Note that this method does not create any file.\)
parameter: file: monitored file
return: monitor object
throws: if the file path cannot be canonicalized

## Static Method: create
- parameter: `folder`, type: `java.io.File`
- parameter: `filename`, type: `java.lang.String`
- parameter: `singlefile`, type: `boolean`
- return type: `com.pnfsoftware.jeb.util.io.FileMonitor`

Description: Create a monitor object for the provided file or group of files. \(Note that this method does not create any file.\)
parameter: folder: folder containing lock files
parameter: filename: monitored file name or filename prefix
parameter: singlefile: true for one lock file, false for prefix\-based lock files
return: monitor object
throws: if the folder path cannot be canonicalized

## Static Method: get
- parameter: `file`, type: `java.io.File`
- return type: `com.pnfsoftware.jeb.util.io.FileMonitor`

Description: Retrieve the existing monitor for the provided file.
parameter: file: monitored file
return: existing monitor, or null
throws: if the file path cannot be canonicalized

## Static Method: get
- parameter: `folder`, type: `java.io.File`
- parameter: `filename`, type: `java.lang.String`
- parameter: `singlefile`, type: `boolean`
- return type: `com.pnfsoftware.jeb.util.io.FileMonitor`

Description: Retrieve the existing monitor for the provided file or group of files.
parameter: folder: folder containing lock files
parameter: filename: monitored file name or filename prefix
parameter: singlefile: true for one lock file, false for prefix\-based lock files
return: existing monitor, or null
throws: if the folder path cannot be canonicalized

