public class SimpleWriter extends Writer
Writer.
Subclass can override onNewFileCreated(File) and do some initialization work to the new
file, such as calling appendLog(String) to add a file header.
| Constructor and Description |
|---|
SimpleWriter() |
| Modifier and Type | Method and Description |
|---|---|
void |
appendLog(java.lang.String log)
Append the log to the end of the opened log file, normally an extra line separator is needed.
|
boolean |
close()
Make sure the opened log file is closed, normally called before switching the log file.
|
java.io.File |
getOpenedFile()
Get the opened log file.
|
java.lang.String |
getOpenedFileName()
Get the name of opened log file.
|
boolean |
isOpened()
Whether a log file is successfully opened in previous
Writer.open(File). |
void |
onNewFileCreated(java.io.File file)
Called after a log file is newly created.
|
boolean |
open(java.io.File file)
Open a specific log file for future writing, if it doesn't exist yet, just create it.
|
public boolean open(java.io.File file)
Writerpublic boolean isOpened()
WriterWriter.open(File).public java.io.File getOpenedFile()
WritergetOpenedFile in class Writerpublic java.lang.String getOpenedFileName()
WritergetOpenedFileName in class Writerpublic void onNewFileCreated(java.io.File file)
You can do some initialization work to the new file, such as calling appendLog(String)
to add a file header.
Called in worker thread.
file - the newly created log filepublic void appendLog(java.lang.String log)
Writer