> ## 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.

# fileRead

> インプットファイルの内容を読み出して、そのデータを単一の文字列としてアウトプットアイテムに返します。さまざまな文字エンコーディングおよびバイナリエンコーディングをサポートします。

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

## 必要なパラメータ

* **file**：読み出すファイル名。

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

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

## アウトプット属性

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

## 例

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

```xml theme={null}
<!-- 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>
```

### カンマをパイプ文字（ | ）に置き換える

```xml theme={null}
<!-- 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>
```
