wood burning stoves 2.0*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java 5 and Binary Files" Watch "Java 5 and Binary Files" New topic
Author

Java 5 and Binary Files

James Chegwidden
Author
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: 13884
    
  10

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java 5 and Binary Files
 
Similar Threads
Dealing with Ini Files
DataInputStream Help needed while creating file
about stream
DataOutputStream(new FileOutputStream(aFile, true));
How to Change the File Name for Each Uploaded Files to the Socket Server?