fileRead

Version 23.4.8841


fileRead


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

必要なパラメータ

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

オプションのパラメータ

  • encoding:使用するエンコーディング。許容される値は、使用されているJVM / OS によって決まります。主なオペレーティングシステムやJVM で一般的にサポートされているエンコーディングの値には、UTF-8ASCIIBASE64windows-1252、およびISO-8859-2 があります。デフォルトはUTF-8 です。

アウトプット属性

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

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

<!-- Creating the input item and setting the file attribute -->
<arc:set attr="input.file" value="[FilePath]" />
<!-- Calling fileRead and passing in the input item and setting the encoding of the output -->
<arc:call op="fileRead" in="input" out="result" >
  <arc:set attr="fileOut.encoding" value="BASE64" />
  <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>