erlang 进行文件操作
{ok, Write} = file:open("test.txt",[write]),
io:format(Write, "~s", ["string"] ).
但是这样做每次读都会覆盖文件内容
{ok, Write} = file:open("test.txt",[<span style="color:#FF0000;">append</span>]),
io:format(Write, "~s", ["string"] ).
这样就可以追加
其实知识在
file:open的参数里有。。不过有时候真心翻着麻烦
write
The file is opened for writing. It is created if it does not exist. If the file exists,
and if write is not combined with read, the file will be truncated.
append
The file will be opened for writing, and it will be created if it does not exist.
Every write operation to a file opened with append will take place at the end of the file.