• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating BufferedStream Object  RSS feed

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While creating object of BufferedReader or BufferedWriter class, do we need to pass, FileInputStream & FileOutputStream Objects, as parameters only??
Or, we can also instantiate these objects else way??
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the API documentation of those classes. BufferedReader has two constructors, which both take a Reader object. So to create a BufferedReader you'll need another Reader object first, for example a FileReader. You can't pass a FileInputStream directly to the constructor of BufferedReader (because a FileInputStream is not a Reader). Likewise for BufferedWriter.
 
Vishnu Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:Look at the API documentation of those classes. BufferedReader has two constructors, which both take a Reader object. So to create a BufferedReader you'll need another Reader object first, for example a FileReader. You can't pass a FileInputStream directly to the constructor of BufferedReader (because a FileInputStream is not a Reader). Likewise for BufferedWriter.


Ok. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!