write hash_map as a json file into a zip file in java

Viewed 39

I need to append a hash map as json file into zip file as new zip entry.

I tried the following code:

Map<String, String> map1 = new HashMap<String, String>(); 
map1.put("a","b");
zipOutputStream.putNextEntry(new ZipEntry("info.json"));
ByteArrayOutputStream ba = new ByteArrayOutputStream();
ObjectOutputStream oba = new ObjectOutputStream(zipOutputStream);
oba.writeObject(map1);
oba.close();

but the above code after executing the contents of the json in the zip file is not proper.

0 Answers
Related