code: private void serializeMap(Map<?,?> map, File file) {
          try(ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))){
              os.writeObject(map);
          } catch (Exception e) {
              logger.error(e.getLocalizedMessage(), e);
          }
      }
docs: Serialize a Map.
  
  @param map The map to serialize.
  @param file The file for saving the map.