So I'm trying to save HashMaps into a file this is what I got so far: This is how I'm saving it: (I put this in OnDisable) Code:java public void savehashmapfile() { try { final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(getDataFolder() + File.separator + "AccessoryInv.bin")); oos.writeObject(accessoryinv); oos.flush(); oos.close(); } catch (final Exception e) { e.printStackTrace(); } } This is how I'm loading it: (I put this in OnEnable) Code:java final File f = getDataFolder(); if (!f.exists()) { f.mkdirs(); } File hashmapfile = new File(getDataFolder() + File.separator + "AccessoryInv.bin"); if (!hashmapfile.exists()) { savehashmapfile(); } else if (hashmapfile.exists()) { try { final ObjectInputStream ois = new ObjectInputStream(new FileInputStream(getDataFolder() + File.separator + "AccessoryInv.bin")); final Object result = ois.readObject(); ois.close(); accessoryinv = (HashMap<UUID, Inventory>) result; } catch (final Exception e) { e.printStackTrace(); } } My Hashmap: Code:java private HashMap<UUID, Inventory> accessoryinv = new HashMap<UUID, Inventory>(); //Last inventory of the player And the rest of the code I'm just saving the UUId of the player and the inventory to the hash map. My file isn't reading it correctly. Because my hashmap still gets removed when I restart my server. A little help would be appreciated!
shohouku I hope you are using 'onDisable' and 'onEnable' (note the casing of the 'o'). That aside, I am not sure how serializable Inventory is ;3