Hello, guys.
I wanna read first 60 bytes of a large file.
Currently, I have tried File.read!/1
and File.stream!/3
.
File.read!/1
It reads entire files. Not what I need.
File.stream!/3
I saw the official example:
# Read in 2048 byte chunks rather than lines
File.stream!("./test/test.data", [], 2048)
#=> %File.Stream{line_or_bytes: 2048, modes: [:raw, :read_ahead, :binary],
#=> path: "./test/test.data", raw: true}
Even if it reads one chunk whose size is 2048 byte every time, It always streams entire file.
Last
How to read the first 60 bytes of a large file?