qie.writeFile¶
Signature: qie.writeFile(file, value, shouldCreatePath*)
Returns: void
Creates a new file and writes value as the contents of this newly created file.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String, File, or NetFile | file | the file to write. This can be either a string representing the file's full path and file name (i.e. 'c:\\temp\\file.txt'), a java.io.File object or a com.qvera.qie.utils.NetFile object. | |
| String or byte[] | value | the contents of the file to be written | |
| Boolean | shouldCreatePath* | (optional) true, to create the path of the file if it doesn't exist; false, otherwise | false |
Example¶
// Write file examples:
// Example: file as String path, value as String
qie.writeFile(
"/tmp/mine.txt",
"Sample text written to file.",
true
);
// Example: file as File, value as String
var fileObject = qie.newFile("/tmp/mine-file.txt");
qie.writeFile(
fileObject,
"Sample text written using a File object.",
true
);
// Example: file as String path, value as byte[]
var byteValue = [
83,97,109,112,108,101,32,98,121,116,101,32,99,111,110,116,101,110,116
]; // "Sample byte content"
qie.writeFile(
"/tmp/mine-bytes.txt",
byteValue,
true
);