public class DataFileWriter extends ByteStream
Class for buffered writing of data files (binary format).
empty
Modifier and Type | Method and Description |
---|---|
static DataFileWriter |
append(java.lang.String file)
Open a data file for append access.
|
void |
close()
Close the file.
|
void |
flush()
Flush buffered contents to the file.
|
static DataFileWriter |
open(java.lang.String file)
Open a data file for write access.
|
DataFileWriter |
withBufferSize(int size)
Alter the buffer size.
|
void |
writeBinary(byte[] data)
Write data content to the file.
|
void |
writeByte(byte value)
Write data content to the file.
|
static void |
writeFile(java.lang.String file,
byte[] data)
Write a
file to contain data . |
asText, copyTo, copyTo, copyToFile, fileWriter, fromBinary, fromBinary, fromBinary, fromFile, fromInput, fromText, getCanUndo, getDataType, readAndClose, readBinary, readBinary, readByte, toBuffer, toInput, toString, undoRead, withUndo
getEntityTag, getFileName, getMediaType, setEntityTag, setFileName, setMediaType
cloneMutable, equals, getTypeCode, hashCode
public static DataFileWriter append(java.lang.String file)
Open a data 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 DataFileWriter open(java.lang.String file)
Open a data file for write access. Recreates the file if already exists.
file
- File name.public DataFileWriter withBufferSize(int size)
Alter the buffer size. Should be called after DataFileWriter.append
/ DataFileWriter.open
, but before writing content.
size
- Buffer size.public void writeBinary(byte[] data)
Write data content to the file. Text is converted to UTF-8 format for writing.
writeBinary
in class ByteStream
data
- Data content.public void writeByte(byte value)
Write data content to the file.
writeByte
in class ByteStream
value
- Data content.public static void writeFile(java.lang.String file, byte[] data)
Write a file
to contain data
.
file
- File name.data
- Data content.