• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I/O

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FilterInputStream can not use FileInputStream object as argument.
Example:
FileInputStream fs=new FileInputStream("test.java");
FilterInputStream fi=new FilterStreamInputStream(fs);//compile is not ok
But I can code following :
DataInputStream di=new DataInputStream(fs);//compile is ok
Why? I get confusion.
I think FileInputStream is a subclass of InputStream.It sould be used in FilterInputStream constructor.Why compiler complain?
Who know reason,please explain.
Thank you.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason is, the constructor for FileInputStream class has protected access whereas for DataInputStream it is public.
It has nothing to do with the use of object of a FileInputStream. That is perfectly O.K.

------------------
reply
    Bookmark Topic Watch Topic
  • New Topic