当将inputStream转换为ObjectInputStream时,我会得到这个错误。请在这件事上帮我。
我的守则:
InputStream isSchema = Thread.currentThread()
.getContextClassLoader().getResourceAsStream("schema.xsd");
ObjectInputStream inputStream = new ObjectInputStream(isSchema);例外:
java.io.StreamCorruptedException: invalid stream header: 3C787364发布于 2015-04-21 10:54:43
十六进制中的3C787364是<xsd。
schema.xsd不是以前使用ObjectOutputStream编写的序列化对象文件。您必须使用InputStreamReader。
只是一个例子,
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(); https://stackoverflow.com/questions/29769191
复制相似问题