So I have this class called World:
public class World implements Serializable {
private int dx;
private int dy;
private int x;
private int y;
private Path path;
public ImageIcon image;
public ArrayList<Location> locations;
I was serializing and deserializing it just fine before I added an object to the ArrayList<Location> locations;
Now when I try to run the serialization
try {
FileOutputStream fos = new FileOutputStream(Main.board.worldpath.toString());
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(Main.board.world.image);
oos.writeObject(Main.board.world);
oos.close();
}catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
It throws java.io.NotSerializableException: sun.nio.fs.WindowsPath in this line oos.writeObject(Main.board.world);
The class Location is also serializable:
public class Location implements Serializable {
public int x;
public int y;
public String name;
public String desc;
I'm not sure why it would say that it's not serializable so is there anything special about serializing ArrayLists?