파일에서 읽은 행을 문자열 목록으로 자르려고합니다. 이것은 항상 해결할 수없는 예외를 발생시킵니다.문자열 뒤의 erlang 예외 : 파일에서 읽은 행의 토큰
exception error: no function clause matching string:tokens1
(<<"Cascading Style Sheets CSS are an increasingly common way for website developers to control the look\n">>," ,.",[]) in function readTest:run/1
-module(readTest).
-export([run/1]).
open_file(FileName, Mode) ->
{ok, Device} = file:open(FileName, [Mode, binary]),
Device.
close_file(Device) ->
ok = file:close(Device).
read_lines(Device, L) ->
case io:get_line(Device, L) of
eof ->
lists:reverse(L);
String ->
read_lines(Device, [String | L])
end.
run(InputFileName) ->
Device = open_file(InputFileName, read),
Data = read_lines(Device, []),
close_file(Device),
io:format("Read ~p lines~n", [length(Data)]),
Bla = string:tokens(hd(Data)," ,."),
io:format(hd(Data)).
쉽게 실패 할 수 있습니다. 에를랭에서 막 시작했습니다.
(도움을 청합니다.) 어리석은 실패 – prototyp