The moose likes Java in General and the fly likes Java 5 and Binary Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java 5 and Binary Files" Watch "Java 5 and Binary Files" New topic

Java 5 and Binary Files

James Chegwidden
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
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

Author and Instructor, my book
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15037

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 does not have a constructor that takes a as the argument. You could have discovered that quickly by writing a small program yourself.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
subject: Java 5 and Binary Files
jQuery in Action, 3rd edition