Companion object for AppendableWriter providing factory methods for creating instances.
The AppendableWriter allows for efficient and convenient appending of string data to files or other writable resources via a BufferedWriter. The factory methods in the companion object ensure flexibility by enabling creation from file names, File instances, FileWriter objects, or directly from BufferedWriter instances.
Creates an AppendableWriter instance for the given file name.
Creates an AppendableWriter instance for the given file name.
The file name must not be null or empty and should start with a forward slash ("/") and end with ".txt". If these conditions are not met, an IllegalArgumentException will be thrown. This method internally constructs a File instance and delegates creation to another apply method.
Value parameters
name
the name of the file (must be non-null, non-empty, start with "/", and end with ".txt")
Attributes
Returns
an AppendableWriter instance associated with the specified file
Throws
IllegalArgumentException
if name is null, empty, does not start with "/", or does not end with ".txt"
Creates a new instance of AppendableWriter using the provided FileWriter.
Creates a new instance of AppendableWriter using the provided FileWriter.
The AppendableWriter wraps the FileWriter with a BufferedWriter, enabling efficient writing operations, and provides an interface for appending string content.
Value parameters
fileWriter
the FileWriter to be wrapped, enabling appending functionality to the file
Attributes
Returns
a new AppendableWriter instance wrapping the provided FileWriter