Here you can find the source of putMapValue(String path, Object value, Map
public static void putMapValue(String path, Object value, Map<String, Object> map)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { public static void putMapValue(String path, Object value, Map<String, Object> map) { if (path == null || path.trim().isEmpty()) { return; }//from ww w .j ava 2s . c o m String[] split = path.split("\\."); Map<String, Object> targetMap = map; for (int i = 0; i < split.length - 1; i++) { String key = split[i]; Object intermediateMap = (Map<String, Object>) targetMap.get(key); if (!(intermediateMap instanceof Map)) { throw new IllegalArgumentException(String.format("No such property [%s].", key)); } targetMap = (Map<String, Object>) intermediateMap; } targetMap.put(split[split.length - 1], value); } }