Class TextFileOutput
Object
TextFileOutput
Utility for writing to a text-file at a particular path, but only if it is enabled.
If a file is disabled, the methods can be called as normal, but no text-file is creates and no content is written.
To write contents, a sequence should be followed:
- Call
start(). - Call methods on
getWriter()to write content. - Call
end().
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidend()This should be called once after writing all content withgetWriter()ThePrintWriterused for writing the text file.booleanWhether the writer is enabled to write to the file-system.voidstart()This should be called once before subsequently writing content withgetWriter()
-
Constructor Details
-
TextFileOutput
Creates a newTextFileOutputinstance.- Parameters:
filePath- The path to which the text-file is written.
-
-
Method Details
-
start
This should be called once before subsequently writing content withgetWriter()- Throws:
OutputWriteFailedException- if unable to write content tofilePath.
-
isEnabled
public boolean isEnabled()Whether the writer is enabled to write to the file-system.- Returns:
- true iff the writer is enabled, otherwise it is disabled and no content is written.
-
end
public void end()This should be called once after writing all content withgetWriter() -
getWriter
ThePrintWriterused for writing the text file.
-