Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.openide.filesystems 6.4.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.openide.filesystems
Class FileLock

    java.lang.Object
      org.openide.filesystems.FileLock

    public class FileLock

extends Object

Represents an acquired lock on a `FileObject`. Typical usage includes locking the file in the editor on first modification, and then using this object to ensure exclusive access when overwriting the file (saving) by using `FileObject.getOutputStream(org.openide.filesystems.FileLock)`. Also used for renames, deletes, &c.

Note that such locks are only used to protect against concurrent write accesses, and are not used for read operations (i.e. they are not write-one-read-many locks). Normally this is sufficient protection. If you really need an atomic read, you may simply lock the file, perform the read, and unlock it when done. The file will still be protected against writes, although the read operation did not request a lock.

See Also:
  `FileObject`

Field Summary
`static FileLock` | `NONE` Constant that can be used in filesystems that do not support locking.

Constructor Summary
`FileLock()`

Method Summary
`void` | `finalize()` Finalize this object.
`boolean` | `isValid()` Test whether this lock is still active, or released.
`void` | `releaseLock()` Release this lock.

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NONE

    public static final FileLock NONE

  Constant that can be used in filesystems that do not support locking. Represents a lock which is never valid.

Constructor Detail

### FileLock

    public FileLock()

Method Detail

### releaseLock

    public void releaseLock()

  Release this lock. In typical usage this method will be called in a `finally` clause.

### isValid

    public boolean isValid()

  Test whether this lock is still active, or released.

  Returns:
    `true` if lock is still active

### finalize

    public void finalize()

  Finalize this object. Calls `releaseLock()` to release the lock if the program for some reason failed to.

  Overrides:
    `finalize` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.openide.filesystems 6.4.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.