English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang File file_read Method

Files in Erlang

There is a way to read all the content of a file at once. This is done through the file_read method. The details of the command are as follows.

Syntax

file_read(filename)

Parameter

  • filename −This is the name of the file to be read.

Return Value

All content of the file.

-module(helloworld). 
-export([start/0]). 
start() -> 
   Txt = file:read_file("Newfile.txt"), 
   io:fwrite("~p~n",[Txt]).

When we run the above program, we will get the following result.

{ok,<<"Example1\nExample2\nExample3">>}

Files in Erlang