Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java 5 and Binary Files

 
James Chegwidden
Author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the combination of FileInputStream/FileOutputStream with DataInputStream/DataInputStream still the prefered way to teach Binary Files in Java 5.

Some books use File class since it handles both text and binary files- but it add another layer of chaining:



Could a DataOutputStream directly handle the File class:


Haven't tryed it yet- asking for opinions about the Binary Files at this point..Thanks JC
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15279
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The File class is just a representation of a pathname or filename in the file system. It doesn't have anything to do with the contents of the file.

Your second piece of code will not compile, because class java.io.DataOutputStream does not have a constructor that takes a java.io.File as the argument. You could have discovered that quickly by writing a small program yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic