Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File and FileReader/Writer  RSS feed

 
Pratiti Naphade
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1)what is the need of FileWriter/Reader if there exists File class?
Q2)Can u instantiate FilterInputStream?if yes how do u do it
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pratiti Naphade:
Q1)what is the need of FileWriter/Reader if there exists File class?

A File is just a reference to a file at some specific location. You can get information about the file and it's attributes, but you can't do a whole lot with the file itself. FileReader/FileWriter allow you to actually read and write from the file.

Q2)Can u instantiate FilterInputStream?if yes how do u do it

Can't answer that one. Sorry.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can instantiate a FilterInputStream. It takes an InputStream as a single parameter. By itself it does nothing except pass all requests to the underlying InputStream. You have to override a method and do something with the data from he stream in order for the FilterInputStream to be of any value.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!