Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ObjectInput & ObjectOutput Streams

 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Asim Khan's note it is written that,

ObjectInptStream & ObjectOutputStream are processing streams, so it mutst be constructed on another stream(a data sink stream rather,like FileOutputStream)
.
My question is that both ObjectInput & ObjectOutput Streams have two constructor one of which does not take any arguments, i.e default constructor.So how we will construct ObjectInput & ObjectOutput Streams using this constructor.
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikrama,
The only way you can use the protected constructor which accepts no parameters is to sublcass the ObjectInputStream or ObjectOutputStream. The no arg constructor is needed so that subclasses don't need to create any extra data just to get the functionality correct.
Just using the I/O methods in any java program will not allow you to call the no argument constructor.
Regards,
Manfred.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic