The flat file transport strategy uses the Java 1.5 File Channel feature to facilitate locking the events file when writing events. This strategy allows for external programs to adopt a file locking strategy when accessing this file.

Since the java.nio.FileChannel and java.nio.FileLock classes make use of native system concurrent file access capabilities, the external programs can make use of system-level, concurrent access methods, without concern as to whether these are compatible with the locking used by the FlatFile transport.

For those programs that are Java-centric, the java.nio.FileChannel and java.nio.FileLock classes are recommended when reading events from the event file.

The following code fragment illustrates a suggested approach.

. . .
FileOutputStream fos = new FileOutputStream("<eventfilename>");
DataOutputStream dos = new DataOutputStream(new BufferOutputStream(fos));
FileChannel channel = fos.getChannel();
FileLock lock = channel.lock();
try {
    . . . read and/or write data . . .
} catch (Exception e) {
    . . . handle exceptions . . .
} finally {
    lock.release();
}
. . .