File input/output: Difference between revisions

m
No edit summary
Line 1,802:
 
=={{header|Julia}}==
Here we read the content of file1 into the variable stringmystring. Then we write the content of string to file2.
<lang Julia>stringmystring = openread(readall, "file1", "r"String)
open(io->write(io, stringmystring), "file2", "w")</lang>
Note however that Julia has a `cp` function to copy the content of a file to another file.
<lang julia>cp("file1","file2")</lang>
Line 1,810:
<lang Julia>infile = open("file1", "r")
outfile = open("file2", "w")
write(outfile, readallread(infile, String))
close(outfile)
close(infile)</lang>
Here is a one-liner that guarantee that the file handle is closed
even if something goes wrong during the read/write phase.
<lang Julia>open(IO ->write(IO, openread(readall, "file1", "r"String)), "file2", "w")</lang>
 
=={{header|K}}==
4,105

edits