What is the difference between character stream and byte stream?
Love_To_Learn
2011-03-13 11:33:36 UTC
I can't understand their definition. What do you mean by that one works with characters and this one works with bytes. Besides each character takes only one byte. This means that there seems to be no difference between the two streams. Please clear my doubt.
Thanks in advance.
Three answers:
deonejuan
2011-03-13 12:26:05 UTC
In Java anyway, a byte stream does not care about any encoding, whereas the character stream will have to read two bytes and convert. There is a slight overhead for character, but negligible. A character stream can be read in a line at a time -- looking for 'newline' character(s), each OS has its own special combination or single character for that.
But both read an integer. You serialize an Object as a byte stream because it can be more than just characters.
2011-03-13 11:41:01 UTC
Some characters take more than one byte. Chinese hieroglyphs can take four 草你妈.
So, character stream can take some logic to match up its parts to get the whole.
2011-03-13 11:40:46 UTC
Are you talking about the difference between strings and integers?
What language are you learning it in? maybe i will be able to give you examples with the language you are learning.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.