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!

java.io.StreamCorruptedException: invalid stream header

807607Jan 18 2007 — edited Jan 21 2007
HI,
I am trying to write a simple application to transfer the files in a local directory to a remote server. I found a problem from the begining that am not able to resolve. Trying to identify the problem i just write this program:

public class TestFIS{

public static void main (String argv[]) {

try{
FileInputStream fis = new FileInputStream("i_sname.dbf");
ObjectInputStream ois = new ObjectInputStream(fis);
File file2 = (File) ois.readObject();
String name=file2.getName();
System.out.println(name);
ois.close();
}

catch(Exception e) {
e.printStackTrace();
}

}

But still throws the same exception:
java.io.StreamCorruptedException: invalid stream header

the stacktrace is:

java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783
)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
at TestFIS.main(TestFIS.java:13)

i checked everything but couldn't get a solution and now i desperately need to know what am doing wrong. So i will appreciate if someone can tell me what's going on.

Thank you very much
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2007
Added on Jan 18 2007
10 comments
14,049 views