0

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;
    }
}
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
Hafizi
  • 39
  • 8
  • Maybe https://stackoverflow.com/questions/11745771/objectinputstream-readobject-classnotfoundexception?rq=1 I would tend to think you don't have a `Bus` class on android side or that the format of the serialized class is not OK for the dalvik VM. My advice: use json to serialize the data –  Jan 13 '17 at 05:47
  • I dont think that problem is similar as mine . I'm just trying to deserialize a file and im not using any server or other thing :( – Hafizi Jan 13 '17 at 05:48

0 Answers0