> Erlang中文手册 > write_file/2 向文件写入数据

file:write_file/2

向文件写入数据

用法:

write_file(Filename, Bytes) -> ok | {error, Reason}

向文件 Filename 写入数据 Bytes。如果文件 Filename 不存在,则创建,存在则覆盖原来的。

Data = "{person, 'kalle', 25}.",
file:write_file("/app/test.txt", list_to_binary(Data)).