0

Why if we want to zip a file in java we always use FileInputStream and BufferedInputStream rather than BufferedReader and FileReader?

icza
  • 389,944
  • 63
  • 907
  • 827
Sunset
  • 9
  • 2

1 Answers1

1

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.

icza
  • 389,944
  • 63
  • 907
  • 827