• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

io basic question

 
Rakesh Bagaria
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we have FileInputStream Class for input purpose then why we need DataInputStream ?please Explain
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh Bagaria wrote:when we have FileInputStream Class for input purpose then why we need DataInputStream ?please Explain


They're different beasts, and the API tells you why. The first is for getting bytes out of files, and often this is wrapped in another IO class such as a DataInputStream to get primitives out of the file, or ObjectInputStream to get objects out, or Readers to get text, or...

While the latter is to get primitives out of a stream, any stream be it a FileInputStream, or a Stream from any other source.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic