i**p 发帖数: 902 | 1 I use ObjectOutputStream to write an object to a file by Java 1.6. Though
the object in the file can be read by Java application,the Android App (also
compiled by Java 1.6 in Eclipse) cannot read the same object by
ObjectInputStream. The object does implement java.io.Serializable.
Does anyone know the reason?
Thanks! |
m****r 发帖数: 6639 | 2 what is the error?
also
【在 i**p 的大作中提到】 : I use ObjectOutputStream to write an object to a file by Java 1.6. Though : the object in the file can be read by Java application,the Android App (also : compiled by Java 1.6 in Eclipse) cannot read the same object by : ObjectInputStream. The object does implement java.io.Serializable. : Does anyone know the reason? : Thanks!
|
i**p 发帖数: 902 | 3 e.getMessage() returns the class name "Header"
This is the code to in Android App to read the object.
try {
FileInputStream fin = new FileInputStream(file);
ObjectInputStream sin = new ObjectInputStream(fin);
Header header = (Header)sin.readObject();
} catch (Exception e) {
Log.e("Err", e.getMessage());
}
------------------------
Here is code in Java application to write the file
try {
FileOutputStream f = new FileOutputStream(file);
ObjectOutputStream s = new ObjectOutputStream(f);
Header header = new Header();
s.writeObject(header);
s.flush();
s.close();
f.close();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
} |
h*****0 发帖数: 4889 | 4 写和读的程序是一起编译的吗?
你试试自己指定uid
also
【在 i**p 的大作中提到】 : I use ObjectOutputStream to write an object to a file by Java 1.6. Though : the object in the file can be read by Java application,the Android App (also : compiled by Java 1.6 in Eclipse) cannot read the same object by : ObjectInputStream. The object does implement java.io.Serializable. : Does anyone know the reason? : Thanks!
|