Public Member Functions | |
ErrorLogFile (int timeout, String prefix, String suffix, String folder, boolean deleteOnExit, boolean retryOnError) | |
Override synchronized void | run () |
synchronized void | append (String str) throws IOException |
synchronized void | copy (OutputStream file) throws FileNotFoundException, IOException |
synchronized void | clear () |
synchronized String | getFileName () |
Protected Member Functions | |
Override void | finalize () throws Throwable |
Private Member Functions | |
void | initTmpFile () throws IOException |
Private Attributes | |
Timer | timer = new Timer("ErrorLogFile",true) |
final int | timeout |
long | lastWriteTime = -1 |
final boolean | deleteOnExit |
final boolean | retryOnError |
final String | prefix |
final String | suffix |
final String | folder |
String | fileName |
FileOutputStream | outFile = null |
boolean | fileError = false |
ErrorLogFile
encapsulates a file adding methods to close the file when it has not been since used for long time.
In case of error while writing or creating the temporary file, the behavior depends on the value of retryOnError
. If it is true
.
The purpose of this class is to avoid having a file open when no I/O is performed for a long time. This is achieved:
|
Constructor.
|
|
Append a string to the temporary file.
|
|
Close the file(s) freeing all the resources This is the last method executed by this class |
|
Copy the file in the passed output stream
|
|
Flush and close the file when the object is destroyed by the GC |
|
|
|
Create the temporary file for flushing the log.
|
|
The method executed by the
|
|
If |
|
Remember if there was an error associated to the temporary file for flushing errors.
The behavior of object of this class when an error happens depends on the value of |
|
The name of the file for I/O. |
|
The folder where the temporary file must be written |
|
The time when the last written has been performed.
This can be indirectly used to know if the file is empty as it happens in |
|
The file stream for output. |
|
The prefix of the temporary file |
|
If |
|
The suffix of the temporary file |
|
The number of seconds before closing the file |
|
The timer to check the time before two flush. |