Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Difference between InputStream and InputStreamReader  RSS feed

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there..

I read that InputStream is used for byte based reading it reads 1 byte at a time.
And InputStreamReader is used for charcter based reading so it reads one charcter at a time so no need to convert this first to int then read it.

Here is reading using InputStream.


and here is reading using InputStreamReader




so what is difference between InputStream and InputStreamReader in both case i have to use a Int and then read it and at the end if I want to print that data I have to cast that with "(char)c".

So what is advantage of using InputStreamReader?


Thanks
 
Marshal
Posts: 5629
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the docs:

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset.



IRL you probably want:

 
Marshal
Posts: 62180
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure I have sent you to the Java Tutorials before, but you should find answers to all your questions in there.

If you are starting, start by learning NIO2 rather than the older input classes.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!