File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes InputStreamReader!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "InputStreamReader!!" Watch "InputStreamReader!!" New topic


Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
hi folks,
i found the following about the InputStreamReader:
i don't really understand when it says from bytes to it true that everything written in console is byte that needs to be converted in characters like shown in above code snippet? it would be great help if you explain me this concept in layman's term.
[ July 07, 2003: Message edited by: Namaste Sathi ]
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
hi sathi
here is what i understand.
Byte streams can work with any streams (as anything essentially is a byte format).
Character streams is a easy way of handling data "if we know the data is character data".
- if we wonna read image then we don't use Character stream as u can't really print image the way u 'd display characters, right?
- if we wonna read a file that has some user data which is a text then we use Character stream rather than the Byte stream to have greater advantage of methods like readLine() and things...
now, when we need InputStreamReader()???
when the input source can't be predicted till runtime the API methods (java api or custom api) can return byte stream object as we can read any data with byte streams BUT if we know (being in specific application) that the input is always a file having ascii characters then we can use InputStreamReader as bridge b/w byte stream that we get from the API method and the Readers we have in our code to deal input data as characters.
I agree. Here's the link:
subject: InputStreamReader!!
It's not a secret anymore!