Advertisement
krot

readlines

Dec 17th, 2019
2,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.28 KB | None | 0 0
  1. readlines(FileName) ->
  2.     {ok, Device} = file:open(FileName, [read]),
  3.     try get_all_lines(Device)
  4.       after file:close(Device)
  5.     end.
  6.  
  7. get_all_lines(Device) ->
  8.     case file:read_line(Device) of
  9.     {ok,Data} ->[string:trim(Data)|get_all_lines(Device)];
  10.     _->[]
  11.     end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement