由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - File generated by Java cannot be read by Android App
相关主题
Java 求解2How to write a file to the same directory of the class file?
Java的中文读写问题Problem on ANT,JAVA,JSP,JSPPrecompiler
文件是要放在同目录下的吗?what's inside an java object?
Java复制objectHow to know the size of a java object ?
what is $1.class file in Java?其实JSP也不错
这段实例化的代码可以优化提速吗?探讨一个 ORM + web service 的问题
新手请教怎样在Java里读文本文件中的内容jsp文件不能compile是咋回事?
How to append something on a file?网页的Form中Post的问题 (转载)
相关话题的讨论汇总
话题: java话题: header话题: file话题: app话题: android
进入Java版参与讨论
1 (共1页)
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!

1 (共1页)
进入Java版参与讨论
相关主题
网页的Form中Post的问题 (转载)what is $1.class file in Java?
[合集] 谁能解释一下这里的protected specifier这段实例化的代码可以优化提速吗?
java可以直接去读txt file里指定的一行吗?新手请教怎样在Java里读文本文件中的内容
这个是JSP的什么技术How to append something on a file?
Java 求解2How to write a file to the same directory of the class file?
Java的中文读写问题Problem on ANT,JAVA,JSP,JSPPrecompiler
文件是要放在同目录下的吗?what's inside an java object?
Java复制objectHow to know the size of a java object ?
相关话题的讨论汇总
话题: java话题: header话题: file话题: app话题: android