1.读取文件:
创建test.dat文件:
{person,woman,
{'12323','121212'},
abc
}.
{tttt}.
1.第一种方式全部读取:
默认读取的是erlang里的数据类型,如读取成功,则返回{ok,Text},否则返回{error,Why}.
2.第二种方式分次读取:
3.按行读取:
4.二进制方式读取:
2.文件写入:
我们可以看出,首先先用file:open(File,write)的形式打开了文件,然后用了io:format(S,"~p.~n",List)的方式读入到S里面。