Two Laptop Bag*
The moose likes I/O and Streams and the fly likes urgent query - diff b/w  byte streams and characters streams Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "urgent query - diff b/w  byte streams and characters streams" Watch "urgent query - diff b/w  byte streams and characters streams" New topic
Author

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

ramchander yshetti
Ranch Hand

Joined: Apr 22, 2006
Posts: 97
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

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
naveen gupta
Ranch Hand

Joined: Apr 12, 2006
Posts: 129
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

Joined: Oct 29, 2001
Posts: 8915
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
GeeCON Prague 2014
 
subject: urgent query - diff b/w byte streams and characters streams