Class Writer

  • Direct Known Subclasses:
    SimpleWriter

    public abstract class Writer
    extends java.lang.Object
    A writer is used to write log into log file.

    Used in worker thread.

    Since:
    1.11.0
    • Constructor Summary

      Constructors 
      Constructor Description
      Writer()  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract void appendLog​(java.lang.String log)
      Append the log to the end of the opened log file, normally an extra line separator is needed.
      abstract boolean close()
      Make sure the opened log file is closed, normally called before switching the log file.
      abstract java.io.File getOpenedFile()
      Get the opened log file.
      abstract java.lang.String getOpenedFileName()
      Get the name of opened log file.
      abstract boolean isOpened()
      Whether a log file is successfully opened in previous open(File).
      abstract boolean open​(java.io.File file)
      Open a specific log file for future writing, if it doesn't exist yet, just create it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Writer

        public Writer()
    • Method Detail

      • open

        public abstract boolean open​(java.io.File file)
        Open a specific log file for future writing, if it doesn't exist yet, just create it.
        Parameters:
        file - the specific log file, may not exist
        Returns:
        true if the log file is successfully opened, false otherwise
      • isOpened

        public abstract boolean isOpened()
        Whether a log file is successfully opened in previous open(File).
        Returns:
        true if log file is opened, false otherwise
      • getOpenedFile

        public abstract java.io.File getOpenedFile()
        Get the opened log file.
        Returns:
        the opened log file, or null if log file not opened
      • getOpenedFileName

        public abstract java.lang.String getOpenedFileName()
        Get the name of opened log file.
        Returns:
        the name of opened log file, or null if log file not opened
      • appendLog

        public abstract void appendLog​(java.lang.String log)
        Append the log to the end of the opened log file, normally an extra line separator is needed.
        Parameters:
        log - the log to append
      • close

        public abstract boolean close()
        Make sure the opened log file is closed, normally called before switching the log file.
        Returns:
        true if the log file is successfully closed, false otherwise