Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Readers and Stream classes can be chained?  RSS feed

 
Ghazala Islam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can we chain Reader classes with Stream classes?One of the practice exam has correct answere for reading a large text file like this:
new BufferedReader(new InputStreamReader(new FileInputStream("file.name")));
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See that InputStreamReader class? That's the bridging class that does the trick.
There is also an OutputStreamWriter for going the other way.
-Barry
 
Ghazala Islam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean to say we can pass FileInputStream as parameter because it is InputStreamreader,but if it was Buffered reader?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!