Elixir ファイル読み込み

2016年7月15日 Posted by PURGE

File読込み。

defmodule FileIO do
    def main do
        {:ok, file} = File.open("sample.txt", [:read, :utf8])
        Enum.each(IO.stream(file, :line), fn(line) ->
            IO.puts line
        end )
        File.close(file)
    end
end

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です