code: public static void writeStringMap(DataOutputStream os, Map<String,String> map) throws IOException {
  		if(map==null) {
  			os.writeInt(-1);
  		} else {
  			Set<Entry<String, String>> es = map.entrySet();
  			os.writeInt(es.size());
  			for(Entry<String,String> e : es) {
  				writeString(os, e.getKey());
  				writeString(os, e.getValue());
  			}
  		}
  
  	}
docs: Write a map
  @param os
  @param map
  @throws IOException