> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# fileWrite

> エンコードされたデータを新規ファイルまたは既存のファイルに書き込みます。書き込みモード（truncate またはappend）や文字エンコーディングを制御できます。

エンコードされたデータを新規ファイルまたは既存のファイルに書き込みます。

## 必要なパラメータ

* **file**：書き込むファイルのフルパス（filename 含む）。ファイルが存在しない場合は作成されます。
* **data**：ファイルに書き込むデータ。

## オプションのパラメータ

* **force**：オペレーションがファイルパラメータに設定したパスに見つからないディレクトリを作成するかどうかを制御。`true` および`false` が使用可能です。デフォルト値は`true` です。
* **mode**：書き込みのモード。`truncate` および`append` が使用可能です。デフォルトは`truncate` で、ターゲットファイルがすでに存在する場合はファイルの内容を上書きします。
* **encoding**：ファイルを作成するときに使用するエンコーディング。許容される値は、JVM / OS によって決まります。デフォルトは`UTF-8` です。

## アウトプット属性

* **file:file**：書き込まれるファイルのフルパス。
* **file:cdate**：ファイルの変更日。

## 例

```xml theme={null}
<!-- Setting the target file, mode and data on the input item. This example pulls data from existing message headers to append to a csv file. -->
<arc:set attr="input.file" value="/tmp/orders.csv"/>
<arc:set attr="input.mode" value="append" />
<arc:set attr="input.data">[header:orderno],[_|now('MM-dd-yyyy HH:mm')],[header:itemsku],[header:itemqty]\n</arc:set>

<!-- Calling fileWrite and passing in the input item -->
<arc:call op="fileWrite" in="input" out="result">
  <!-- Optional: Logging information about the modified file to the application log -->
  <arc:set attr="_log.info" value="The [result.file:file] file was updated at [result.file:cdate] with a new order."/>  
</arc:call> 
```
