Erlang - file_read 方法
有一种方法可以允许一次读取文件的所有内容。 这是通过 file_read 方法完成的。 该命令的详细内容如下。
语法
file_read(filename)
参数
filename − 这是需要读取的文件的名称。
返回值
文件的全部内容。
例如
-module(helloworld). -export([start/0]). start() -> Txt = file:read_file("Newfile.txt"), io:fwrite("~p~n",[Txt]).
输出
当我们运行上面的程序时,我们将得到以下结果。
{ok,<<"Example1\nExample2\nExample3">>}
❮ erlang_file_input_output.html