FileWrite
Writes the contents of a string or binary data to a file.
When called with a file path (string, Path, or File), the file is created/overwritten on disk. When called with an open BoxFile object (from {@code fileOpen()}), the data is written through the file's existing stream, respecting the current mode (write or append) and position. The caller is responsible for closing the file object afterward.
Method Signature
FileWrite(file=[boxfile], data=[any], charset=[string], createPath=[boolean])Arguments
file
boxfile
true
A file path (string, Path, File) to create/overwrite, or an open BoxFile object to write through its stream.
data
any
true
The string or binary byte array of the file content.
charset
string
false
The charset encoding (ignored for binary data). Only applies to path-based writes.
UTF-8
createPath
boolean
false
When true, ensures all directories to the file destination are created. Only applies to path-based writes.
false
Examples
Write a Temporary File
fileWrite( getTempFile( getTempDirectory(), "tempFile" ), "My Data" );
Additional Examples
Related
Last updated
Was this helpful?
