When i run the code below, the objIn.readObject(); throws a exception:
classNotFoundException project.Edge
The project.Edge is the object who i try to read from the file.
Object o = null;
ObjectInputStream objIn = null;
try {
objIn = new ObjectInputStream(new FileInputStream("objects.dat"));
o = objIn.readObject();
} catch (Exception ex) {
ex.printStackTrace();
}
while (o != null) {
//do stuff
}
ex.printStackTrace()rather thanSystem.out.println(ex.getMessage());to see what it is.readObject()only loads the data of a class, not the class itself. Therefore all classes used or referenced inobjects.datmust be available in your project.