fileRead

Version 26.1.9568


fileRead


インプットファイルの内容を読み出して、そのデータをアウトプットアイテムの属性としてプッシュします。

必要なパラメータ

  • file:読み出すファイル名。

オプションのパラメータ

  • encoding:ファイルの生バイトを文字列に変換するための方式。標準的な文字セット(UTF-8、ASCIIなど)を指定した場合、その文字セットを使用して生バイトを_デコード_します。バイナリ値(BASE64、HEXなど)を指定した場合、その値を使用して生バイトを_エンコード_します。主なオペレーティングシステムやJVMで一般的にサポートされているencoding パラメータの値には、UTF-8ASCIIBASE64HEXwindows-1252、およびISO-8859-2 があります。デフォルトはUTF-8 です。

アウトプット属性

  • file:data:インプットファイルからのデータ。

インプットファイルのエンコーディングを変更する

<!-- Creating the input item and setting the file and encoding attributes -->
<arc:set attr="input.file" value="[FilePath]" />
<arc:set attr="input.encoding" value="BASE64" />
<!-- Calling fileRead and passing in the input item -->
<arc:call op="fileRead" in="input" out="result" >
  <!-- The file:data here is now BASE64 encoded based on the value set in input.encoding -->
  <arc:set attr="fileOut.data" value="[result.file:data]" />
</arc:call>

<!-- Checking to make sure the output file has data, else throw an error -->
<arc:check attr="fileOut.data" >
  <arc:set attr="fileOut.filename" value="[FileName]" />
  <arc:push item="fileOut" />
  <arc:else>
    <arc:throw code="NoData" desc="No file data." />
  </arc:else>
</arc:check>

カンマをパイプ文字( | )に置き換える

<!-- Creating the input item and setting the file attribute -->
<arc:set attr="input.file" value="[FilePath]" />
<!-- Calling fileRead and passing in the input item -->
<arc:call op="fileRead" in="input" out="result">]
  <!-- Replacing all commas in the file with pipes and setting the new data on the output item -->
  <arc:set attr="output.data" value="[result.file:data | replace(',','|')]" />
</arc:call>

<!-- Checking to make sure the output file has data, else throw an error -->
<arc:check attr="output.data" >
  <arc:set attr="output.filename" value="[FileName]" />
  <arc:push item="output" />
  <arc:else>
    <arc:throw code="NoData" desc="No file data." />
  </arc:else>
</arc:check>