4 ms·
Imagine you are reading files which can be of varying size (KB to GB). A byte array will do a contiguous allocation of the file size. A Reader can be much more
by ashishb 1y ago
Imagine you are reading files which can be of varying size (KB to GB). A byte array will do a contiguous allocation of the file size.
A Reader can be much more thoughtful. And I say "can be" because someone can make Reader as inefficient as a byte array.
Or they can read in chunks.
For example, if you are trying you read exif data or reading up to first N bytes, Reader is a superior approach.