> ## 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" />
```
