%% 打开文件 {ok, File} = file:open('filename.txt', [read]),

%% 读取文件内容 content = read_file(File, []),

%% 关闭文件 file:close(File).

%% 逐行读取文件内容 read_file(Fd, Acc) -> case io:get_line(Fd, '') of eof -> lists:reverse(Acc); Line -> read_file(Fd, [Line | Acc]) end.

Erlang 获取文件内容代码示例

原文地址: https://www.cveoy.top/t/topic/lQ3K 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录