org.apache.commons.io.output
Class LockableFileWriter
Writer
org.apache.commons.io.output.LockableFileWriter
public class LockableFileWriter
extends Writer
FileWriter that will create and honor lock files to allow simple
cross thread file lock handling. If Writer
attributes
are unspecified, the default behavior is to overwrite (rather than
to append), and to use the value of the system property
java.io.tmpdir
for the lock file directory.
$Id: LockableFileWriter.java,v 1.7 2004/02/23 04:40:29 bayard Exp $
LCK
private static final String LCK
append
private boolean append
lockFile
private File lockFile
writer
private FileWriter writer
LockableFileWriter
public LockableFileWriter(File file)
throws IOException
Constructs a LockableFileWriter. If the file exists, it is overwritten.
LockableFileWriter
public LockableFileWriter(File file,
boolean append)
throws IOException
Constructs a LockableFileWriter.
file
- file to write toappend
- true if content should be appended (default is to overwrite).
LockableFileWriter
public LockableFileWriter(File file,
boolean append,
String lockDir)
throws IOException
Constructs a LockableFileWriter.
file
- file to write toappend
- true if content should be appended (default is to overwrite).lockDir
- Specifies the directory in which the lock file should be held.
LockableFileWriter
public LockableFileWriter(String fileName)
throws IOException
Constructs a LockableFileWriter. If the file exists, it is overwritten.
fileName
- file to write to
LockableFileWriter
public LockableFileWriter(String fileName,
boolean append)
throws IOException
Constructs a LockableFileWriter.
fileName
- file to write toappend
- true if content should be appended (default is to overwrite).
LockableFileWriter
public LockableFileWriter(String fileName,
boolean append,
String lockDir)
throws IOException
Constructs a LockableFileWriter.
fileName
- file to write toappend
- true if content should be appended (default is to overwrite).lockDir
- Specifies the directory in which the lock file should be held.
close
public void close()
throws IOException
createLock
private void createLock()
throws IOException
flush
public void flush()
throws IOException
testLockDir
private void testLockDir(File lockDir)
throws IOException
write
public void write(char[] cbuf,
int off,
int len)
throws IOException
java.io.Writer.write(char[], int, int)