Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/File-input-output/Elixir/file-input-output-1.elixir
Normal file
16
Task/File-input-output/Elixir/file-input-output-1.elixir
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
defmodule FileReadWrite do
|
||||
def copy(path,new_path) do
|
||||
case File.read(path) do
|
||||
# In case of success, write to the new file
|
||||
{:ok, body} ->
|
||||
# Can replace with :write! to generate an error upon failure
|
||||
File.write(new_path,body)
|
||||
# If not successful, raise an error
|
||||
{:error,reason} ->
|
||||
# Using Erlang's format_error to generate error string
|
||||
:file.format_error(reason)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
FileReadWrite.copy("input.txt","output.txt")
|
||||
1
Task/File-input-output/Elixir/file-input-output-2.elixir
Normal file
1
Task/File-input-output/Elixir/file-input-output-2.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
File.cp!("input.txt", "output.txt")
|
||||
Loading…
Add table
Add a link
Reference in a new issue