Most likely a very simple question but how do you save a HashMap with the binaryexporter and importer?
I found "writeStringSavableMap" wich needs a Hashmap<String, Savable> but my hashmap is HashMap<String, Integer> and obvious Integer does not implement Savable.
Surely i dont need to make a savable wrapper for my integer ?
So what is the best way to do this ? Or am i just to blind to see an allready implemented method ?
Thx
Hellmaster.
You can make your own SavableMap, or write it like this:
out.write(map.size());
for (Map.Entry<String, Integer> ent : map.entrySet()){
out.write(ent.getKey());
out.write(ent.getValue().intValue());
}
and out is in this case ? ByteArrayOutputStream ?
and then out is written to the export capsule ?
Hellmaster.
out is OutputCapsule
Saving it that way will work, but i don't see how you can read this back since you need a name for everything.
So i decided to just save them as a separate String array and a int array.
Hellmaster.