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

# fileReadLine

> 從檔案中讀取一行內容，支援指定行號和編碼。

逐行讀取並列舉輸入檔案的內容，並將資料作為輸出屬性推出。

## 必需的參數

* **file**: 讀取的檔名稱。

## 可選的參數

* **separator**：確定每個換行的字元分隔符號。 預設值為換行字元 (`\n`)。
* **encoding**：要使用的編碼。 允許的值由所使用的 JVM/OS 確定。 大多數作業系統和 JVM 通常支援的編碼值包括`UTF-8`、`ASCII`、`BASE64`、`windows-1252`和`ISO-8859-2`。 預設為`UTF-8`。

## 輸出屬性

* **file:line**: 檔案的行號。
* **file:data**：輸入檔案中的資料。

## 範例

此範例僅替換第一行中的一些資料。

```xml theme={null}
<!-- Creating the input item and setting the file attribute -->
<arc:set attr="input.file" value="[FilePath]" />
<!-- Initializing the item to hold the file data minus the first line -->
<arc:set attr="restof.data" value="" />
<!-- Calling the fileReadLine operation and passing in the input item -->
<arc:call op="fileReadLine" in="input" out="result" >
  <!-- Once the operation gets to the first line in the file, perform a replace -->
  <arc:if exp="[result.file:line] == 1">
    <arc:set attr="first.line" value="[result.file:data | replace('Owen','Liu')]" />
    <arc:else>
      <!-- Setting the data for the output file to be the concatenation of the modified first line and the rest of the file data -->
      <arc:set attr="output.data" value="[first.line][restof.data]\n[result.file:data]" />
    </arc:else>
  </arc:if> 
</arc:call>
<arc:set attr="output.filepath" value="[FilePath]" />
<arc:push item="output" />
```
