6 - Input - Output
File reading/writing
open("afile.txt", "w") do f # "w" for writing
write(f, "test\n") # \n for newline
endopen("afile.txt", "r") do f # "r" for reading
filecontent = read(f,String) # attention that it can be used only once. The second time, without reopening the file, read() would return an empty string
print(filecontent)
endopen("afile.txt", "r") do f
for ln in eachline(f)
println(ln)
end
endOther IO
Last updated