Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Read-entire-file/Elixir/read-entire-file.elixir
Normal file
23
Task/Read-entire-file/Elixir/read-entire-file.elixir
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
defmodule FileReader do
|
||||
# Read in the file
|
||||
def read(path) do
|
||||
case File.read(path) do
|
||||
{:ok, body} ->
|
||||
IO.inspect body
|
||||
{:error,reason} ->
|
||||
:file.format_error(reason)
|
||||
end
|
||||
end
|
||||
|
||||
# Open the file path, then read in the file
|
||||
def bit_read(path) do
|
||||
case File.open(path) do
|
||||
{:ok, file} ->
|
||||
# :all can be replaced with :line, or with a positive integer to specify the number of characters to read.
|
||||
IO.read(file,:all)
|
||||
|> IO.inspect
|
||||
{:error,reason} ->
|
||||
:file.format_error(reason)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue