Reputation: 152
I save a serialised class on an android device. Transfer it to a win 10 PC and load the file via:
fis = new FileInputStream(result.get(i));
ois = new ObjectInputStream(fis);
Object obj = ois.readObject();
The class on Android and an win 10 is:
public class ImgLogFile implements Serializable{
byte[] frame;
byte[] result;
String config;
public String getConfig(){
return config;
}
public byte[] getFrame() {
return frame;
}
public byte[] getResult() {
return result;
}
}
When i try to cast the loaded Object into it's class i get:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class [Lde.mtt.smartiePlatform.ImgLogFile; cannot be cast to class de.mtt.smartiePlatform.ImgLogFile ([Lde.mtt.smartiePlatform.ImgLogFile; and de.mtt.smartiePlatform.ImgLogFile are in unnamed module of loader 'app')
I noticed the "L" in front of one path but do not know what it means. How can I fix this ?
Upvotes: 4
Views: 299
Reputation: 147154
[...] class [Lde.[...] cannot be cast to class de.[...]
The [
indicates an array. [L
is an array of the reference type that follows.
So you have serialised an array and are attempting to cast the deserialised object to a type that is not an array.
(Also, it's not a great idea to use Java Serialization.)
Upvotes: 2