krot

readlines

Dec 17th, 2019
397
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.
RAW Paste Data