fileCreate

Version 23.4.8839


fileCreate


Creates a file at the specified path on disk, and optionally writes to it.

Required Parameters

  • file: The full path (including the filename) of the file to create.

Optional Parameters

  • force: Controls whether the operation creates missing directories in the path set in the file parameter. The allowed values are true and false. The default is true.
  • data: The data to write to the file.
  • mode: The mode of writing. The allowed values are truncate and append. The default is truncate, which overwrites the file contents if the target file already exists.
  • encoding: The encoding to use when creating the file. The allowed values are determined by the JVM/OS being used. The default is UTF-8.

Output Attributes

  • file:file: The full path of the file created.
  • file:cdate: The creation date of the file.

Example

<!-- Setting the file location and data on the input item -->
<arc:set attr="input.file" value="/tmp/myfiles/cars.json"/>
<arc:setc attr="input.data">{
  "Cars": [
    {
      "Make": "Toyota",
      "Model": "Camry",
      "Type": "Sedan"
    },
    {
      "Make": "Toyota",
      "Model": "Corolla",
      "Type": "Sedan"
    }
  ]
}
</arc:setc>

<!-- Calling fileCreate and passing in the input item -->
<arc:call op="fileCreate" in="input" out="result">
  <!-- Optional: Logging information about the created file to the application log -->
	<arc:set attr="_log.info" value="A file with the timestamp of [result.file:cdate] was created and written to this path: [result.file:file]"/>  
</arc:call>