Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

urgent query - diff b/w byte streams and characters streams

 
ramchander yshetti
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,
please respond to my query

diff b/w byte streams and characters streams. and for what purpose
the both are used. and which stream is efficient.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a Sun Tutorial on the topic. The page after this one shows reading non-unicode bytes such as ASCII into unicode characters and writing them back out.
 
naveen gupta
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

the byte stream is used in order to read the input byte by byte
and character stream for reading charcter by character

byte stream is more efficient since it is fast
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by naveen gupta:

byte stream is more efficient since it is fast


It is not that simple. The most efficient stream depends on what your requirements are. If you need to process character data, a byte stream may get the data faster but you still need to translate bytes into characters, which makes the difference moot. One should also consider speed of development and ease of maintainance. Why should I code something to translate bytes into characters when there's a class that does it already?
The book Java Platform Performance descibes strategies for measuring performance and the basics on writing efficient Java code. The most important step is the first one, defining your requirements so you know what "efficient" is for your circumstances.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic