When would you prefer byte streams over character streams while performing I/O operations in Java?

  • When dealing with binary data and non-text files, such as images or audio.
  • When working with XML or HTML files that contain text and tags.
  • When you need to perform text-based operations, like reading and writing characters.
  • When you want to handle file I/O in a platform-independent manner.
Byte streams are suitable for reading and writing binary data, while character streams are used for handling text data. Byte streams are ideal for handling non-text files, like images or audio, where individual bytes matter. Character streams are used for text files and automatically handle character encoding.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *