public class TextFileWriter extends CharStream
Class for buffered writing of text files (UTF-8 format).
empty
Modifier and Type | Method and Description |
---|---|
static TextFileWriter |
append(java.lang.String file)
Open a text file for append access.
|
void |
close()
Close the file.
|
void |
flush()
Flush buffered contents to the file.
|
static TextFileWriter |
open(java.lang.String file)
Open a text file for write access.
|
TextFileWriter |
withBufferSize(int size)
Alter the buffer size.
|
void |
writeChar(char value)
Write text content to the file.
|
static void |
writeFile(java.lang.String file,
java.lang.String text)
Write a
file to contain text . |
void |
writeString(java.lang.String text)
Write text content to the file.
|
copyTo, copyTo, copyToFile, fileWriter, fromFile, fromInput, fromString, fromString, fromString, getCanUndo, getDataType, readAndClose, readChar, readLine, readString, readString, toBuffer, toString, undoRead, withUndo, writeLine
getEntityTag, getFileName, getMediaType, setEntityTag, setFileName, setMediaType
cloneMutable, equals, getTypeCode, hashCode
public static TextFileWriter append(java.lang.String file)
Open a text file for append access. Creates the file if it doesn't already exist.
file
- File name.public void close()
Close the file.
close
in class StreamBase
public void flush()
Flush buffered contents to the file.
flush
in class StreamBase
public static TextFileWriter open(java.lang.String file)
Open a text file for write access. Recreates the file if already exists.
file
- File name.public TextFileWriter withBufferSize(int size)
Alter the buffer size. Should be called after TextFileWriter.append
/ TextFileWriter.open
, but before writing content.
size
- Buffer size.public void writeChar(char value)
Write text content to the file. Text is converted to UTF-8 format for writing.
writeChar
in class CharStream
value
- Text content.public static void writeFile(java.lang.String file, java.lang.String text)
Write a file
to contain text
.
file
- File name.text
- Text content.public void writeString(java.lang.String text)
Write text content to the file. Text is converted to UTF-8 format for writing.
writeString
in class CharStream
text
- Text content.