I am beginner programmer in Java and Android language . I'm trying to Serialize a class named Bus using eclipse into Bus.ser and then I tried to open/deserialize the Bus.ser in the Android studio using ObjectInputStream
but it throws an ClassNotFoundException
. I already import the Bus class in the android studio but the exception still occurs
Here is the class that read the Bus.ser
package com.example.hafizi.octranspo;
public class Reader implements Serializable{
private static final long serialVersionUID = 21L;
private static Activity originActivity = null;
public Reader(Activity activity) {
originActivity = activity;
}
public Object run(String filename) {
Object data = null;
try {
InputStream fis = originActivity.getResources().getAssets().open(filename);
ObjectInputStream ois = new ObjectInputStream(fis);
data = ois.readObject();
ois.close();
System.out.println("Read completed");
} catch (Exception e) {
System.out.println("Error to read the file : " + filename);
System.out.println(e);
}
return data;
}
}