gnu.text

Class WriterManager

public class WriterManager extends Object implements Runnable

Manages a collection of Writers, handling automatic closing. This class is useful for making sure that a Writer is closed (and its buffers flushed) when a VM exits. A WriterManager can be usefully passed to the JDK 1.3 method addShutdownHook in Runtime.
Field Summary
static WriterManagerinstance
Method Summary
WriterRefregister(Writer port)
Register a Writer.
booleanregisterShutdownHook()
Try to register this as a shutdown hook.
voidrun()
voidunregister(Object key)
Unregister a Writer.

Field Detail

instance

public static final WriterManager instance

Method Detail

register

public WriterRef register(Writer port)
Register a Writer.

Returns: an object that can be passed to WriterManager.

registerShutdownHook

public boolean registerShutdownHook()
Try to register this as a shutdown hook.

Returns: true on success; false if failure (e.g. if not JDK1.3-compatible).

run

public void run()

unregister

public void unregister(Object key)
Unregister a Writer.

Parameters: key the object returned by the correspodning WriterManager.