• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference b/w Character streams and Byte streams

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
I think this is the right forum for this question. What is the difference between character and byte streams right from the low level implementation to the high level implementation. what I actually feel is there is only one difference and that is when we use the character streams the data will be read as a character (i.e 16 bits) and when we read/write the data as byte stream then it will be done as a byte(i.e 8 bits) and there is no other difference. Can anyone help me out in explaining the whole concept.
Thanks in advance.
Shekar.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the I/O and Streams forum...
[ September 24, 2003: Message edited by: Dirk Schreckmann ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The streams deal in "uninterpreted" bytes. If a file contains six bytes, then you'll read six bytes out of it.
The Reader/Writers deal in character data, and the data is interpreted according to a particular character set encoding (either the default, or one you specify). If that character set uses 16 bits per character, then the Reader will return one character for every 2 bytes in the file. But for encodings like UTF-8, which use a variable number of bytes per character, or Latin-1, which always uses only one byte per character, the Readers and Writers will also do the right thing.
So your summary is basically correct, except that the reality is a little more complicated.
 
reply
    Bookmark Topic Watch Topic
  • New Topic