Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The Java code is

        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("src/Stringdata.txt"));    
        String s=(String)ois.readObject();
        System.out.println(s.toString());

        } catch (IOException e) {

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

            e.printStackTrace();
        }

here am getting java.io.StreamCorruptedException: invalid stream header: 4D6F7374 this error please help me

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
244 views
Welcome To Ask or Share your Answers For Others

1 Answer

An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream. src/Stringdata.txt is probably not a file of serialized objects previously written using an ObjectOutputStream. You probably want to use InputStreamReader instead


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...