Reading from a .dat file
931685Apr 29 2012 — edited Apr 30 2012I 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