2

I am getting this error when converting inputStream into ObjectInputStream. Please help me regarding this.

My Code:

InputStream isSchema = Thread.currentThread()
                    .getContextClassLoader().getResourceAsStream("schema.xsd");
            ObjectInputStream inputStream = new ObjectInputStream(isSchema);

Exception:

java.io.StreamCorruptedException: invalid stream header: 3C787364
Ramkumar
  • 154
  • 5
  • 11

1 Answers1

1

3C787364 in hexadecimal is <xsd .

schema.xsd is not a file of serialized objects previously written using an ObjectOutputStream. You must use InputStreamReader.

Just an example

InputStream inputStream = new FileInputStream("c:\\data\\input.txt");
Reader reader = new InputStreamReader(inputStream);

int data = reader.read();
while(data != -1){
    char theChar = (char) data;
    data = reader.read();
}

reader.close();  
Xstian
  • 8,184
  • 10
  • 42
  • 72