My understanding is a bit clearer. I want to have a better understanding of these concepts.
Jesper de Jong wrote:Streams (InputStream and OutputStream) handle data just as raw bytes, without knowing what those raw bytes mean. How the data should be interpreted is left up to the application that uses the streams.
***Can we create a (real-world) scenario that illustrates the above ?
I thought of an example : Please tell me if its bad or complicated
Two people chat using a chat-program (video, sound, typing simultaneously is allowed) . This program uses ONLY streams to send and receive data. The program at receiver decides whether the incoming data is video/text or sound , and "triggers" the display or speaker accordingly. As an example, 11XXXXXX byte could mean sound received - so send it to speakers for hearing. 00XXXXXX byte could mean text received - so display this in the text part of the UI.
***Readers and writers can handle characters...what if my bytes are video, any classes for that ?
Jesper de Jong wrote:
This is a good example of how different concerns are separated in software: the only responsibility of streams is how to read and write bytes, they don't have to deal with other things like interpreting the data, and the only responsibility of readers and writers is how to interpret the data as characters, without having to know exactly how to read and write bytes. By separating concerns in different layers, both layers can be made simpler, which is good.
***Is it correct that classes such as Writer/Reader make it convenient for a developer to "make sense" of sequences of those bytes in the above example (if it is correct) ? If i did not have such classes i would have to figure a way out myself - Would that be difficult ?
regards
rb
PS: am i on the right track or there are serious flaws in my understanding ?