fileWrite

Version 23.4.8841


fileWrite


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

必要なパラメータ

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

オプションのパラメータ

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

アウトプット属性

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

<!-- 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>