File.read()を使って、ファイルの内容を読み込む。
ファイルの中身(hightemp_1.txt)高知県 江川崎 41 2013-08-12 埼玉県 熊谷 40.9 2007-08-16 岐阜県 多治見 40.9 2007-08-16
ファイルの内容を読み込み、表示するソース
defmodule MyModule do
def fileRead( path ) do
case File.read(path) do
{:ok, body} -> body
{:error, reason} -> reason
end
end
end
IO.puts MyModule.fileRead( "./hightemp_1.txt" )
実行結果
PS C:\Users\tomohiko\Documents\19_elixir> chcp 65001 Active code page: 65001 PS C:\Users\tomohiko\Documents\19_elixir> elixir .\fileread.exs 高知県 江川崎 41 2013-08-12 埼玉県 熊谷 40.9 2007-08-16 岐阜県 多治見 40.9 2007-08-16
0 件のコメント:
コメントを投稿