Tutorial by Examples

Let's assume you have a file lyrics.txt which contains the following data: summer has come and passed the innocent can never last wake me up when september ends Read the entire file at a time By using file:read_file(File), you can read the entire file. It's an atomic operation: 1> file:re...
Write one line at a time Open a file with write mode and use io:format/2: 1> {ok, S} = file:open("fruit_count.txt", [write]). {ok,<0.57.0>} 2> io:format(S, "~s~n", ["Mango 5"]). ok 3> io:format(S, "~s~n", ["Olive 12"]). ok 4&gt...

Page 1 of 1