Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading from a .dat file

931685Apr 29 2012 — edited Apr 30 2012
I have written a program to read from a .dat file but unfortunately it is not functioning well it is given the error below.

java.io.StreamCorruptedException: invalid stream header: 6F72672E



This is the java code pasted below

public FileRead() throws IOException,ClassNotFoundException
{

InputStream f = getClass().getResourceAsStream("all-ergonomics.dat");
File file = new File("C:\\Users\\skliz\\Documents\\NetBeansProjects\\abdul\\src\\input.dat");

FileInputStream fileinput = new FileInputStream(file);
ObjectInputStream object = new ObjectInputStream(fileinput);

String content = (String)object.readObject();


System.out.println("This is the content of the file");
System.out.println();
System.out.println(content);

}




Then below is the content of the .dat file

3




I would be grateful if a response or comment is given on this. Tans
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2012
Added on Apr 29 2012
7 comments
826 views