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

# readfile

> workspace 内の existing regular file を binary mode で読み、その bytes を Lua string として返します。

<div className="real-function-page">
  ```lua theme={null}
  readfile(path: string): string
  ```

  ## エイリアス

  * `readfileasync`

  ## 引数

  <ParamField path={"path"} type={"string"} required>
    separator normalization、workspace-boundary checks、filename/extension checks の後に workspace 内へ解決される File path。Absolute paths は workspace 内に解決される場合だけ受け入れられます。
  </ParamField>

  ## 戻り値

  <ResponseField name={"content"} type={"string"}>
    File contents は明示的な長さを持つ Lua string として返されます。null bytes、line endings、BOM bytes などの bytes は readfile によって変換されません。
  </ResponseField>

  ## 例

  existing workspace file から bytes を読みます。

  ```lua theme={null}
  local path = "examples/config.json"
  writefile(path, '{"enabled":true}')

  local content = readfile(path)
  print(content)
  print(#content)
  ```
</div>
