org.apache.commons.io.output
public class LockableFileWriter extends Writer
This class provides a simple alternative to FileWriter
that will use a lock file to prevent duplicate writes.
By default, the file will be overwritten, but this may be changed to append.
The lock directory may be specified, but defaults to the system property
java.io.tmpdir
.
The encoding may also be specified, and defaults to the platform default.
Version: $Id: LockableFileWriter.java 610010 2008-01-08 14:50:59Z niallp $
Constructor Summary | |
---|---|
LockableFileWriter(String fileName)
Constructs a LockableFileWriter.
| |
LockableFileWriter(String fileName, boolean append)
Constructs a LockableFileWriter.
| |
LockableFileWriter(String fileName, boolean append, String lockDir)
Constructs a LockableFileWriter.
| |
LockableFileWriter(File file)
Constructs a LockableFileWriter.
| |
LockableFileWriter(File file, boolean append)
Constructs a LockableFileWriter.
| |
LockableFileWriter(File file, boolean append, String lockDir)
Constructs a LockableFileWriter.
| |
LockableFileWriter(File file, String encoding)
Constructs a LockableFileWriter with a file encoding.
| |
LockableFileWriter(File file, String encoding, boolean append, String lockDir)
Constructs a LockableFileWriter with a file encoding.
|
Method Summary | |
---|---|
void | close()
Closes the file writer.
|
void | flush()
Flush the stream. |
void | write(int idx)
Write a character. |
void | write(char[] chr)
Write the characters from an array. |
void | write(char[] chr, int st, int end)
Write the specified characters from an array. |
void | write(String str)
Write the characters from a string. |
void | write(String str, int st, int end)
Write the specified characters from a string. |
Parameters: fileName the file to write to, not null
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: fileName file to write to, not null append true if content should be appended, false to overwrite
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: fileName the file to write to, not null append true if content should be appended, false to overwrite lockDir the directory in which the lock file should be held
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: file the file to write to, not null
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: file the file to write to, not null append true if content should be appended, false to overwrite
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: file the file to write to, not null append true if content should be appended, false to overwrite lockDir the directory in which the lock file should be held
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: file the file to write to, not null encoding the encoding to use, null means platform default
Throws: NullPointerException if the file is null IOException in case of an I/O error
Parameters: file the file to write to, not null encoding the encoding to use, null means platform default append true if content should be appended, false to overwrite lockDir the directory in which the lock file should be held
Throws: NullPointerException if the file is null IOException in case of an I/O error
Throws: IOException if an I/O error occurs
Throws: IOException if an I/O error occurs
Parameters: idx the character to write
Throws: IOException if an I/O error occurs
Parameters: chr the characters to write
Throws: IOException if an I/O error occurs
Parameters: chr the characters to write st The start offset end The number of characters to write
Throws: IOException if an I/O error occurs
Parameters: str the string to write
Throws: IOException if an I/O error occurs
Parameters: str the string to write st The start offset end The number of characters to write
Throws: IOException if an I/O error occurs