In the Generating lazy (even infinite) sequences recipe, it was possible to understand the difference between eager and lazy evaluation, namely the use of Enum
or Stream
modules.
When working with files, it is possible to load all of the file's contents into the memory (File.read/1
or File.read!/1
), or the file might be read a line or n bytes at a time (File.stream!/3
). Using the File.stream!
function allows you to work with really large files that might not fit the available memory.
In this recipe, we will read text from a file and output an uppercased version into a new file.