Reputation: 9
Why if we want to zip a file in java we always use FileInputStream
and BufferedInputStream
rather than BufferedReader
and FileReader
?
Upvotes: 0
Views: 152
Reputation: 418435
Readers are used to work with text files, where the content of a file (bytes) are used to represent a text (characters) in some encoding.
On the other hand InputStream
is used in more general way, to read the bytes of a file whatever they mean, so it works for both binary files and text files as well. And zip files and the compression algorithm is designed to work with bytes and not with characters.
Upvotes: 1