借鉴代码

public class StringToMapUtil {

    public static Map<String, String> getValue(String param) {
Map map = new HashMap();
String str = "";
String key = "";
Object value = "";
char[] charList = param.toCharArray();
boolean valueBegin = false;
for (int i = 0; i < charList.length; i++) {
char c = charList[i];
if (c == '{') {
if (valueBegin == true) {
value = getValue(param.substring(i, param.length()));
i = param.indexOf('}', i) + 1;
map.put(key, value);
}
} else if (c == '=') {
valueBegin = true;
key = str;
str = "";
} else if (c == ',') {
valueBegin = false;
value = str;
str = "";
map.put(key, value);
} else if (c == '}') {
if (str != "") {
value = str;
}
map.put(key, value);
return map;
} else if (c != ' ') {
str += c;
}
}
return map;
}
}

最新文章

  1. javascript:window.history.go(-1)
  2. 未将对象引用设置到对象的实例 启用 JIT 调试后,任何无法处理的异常
  3. jquery Mobile应用第2课《构建跨平台APP:jQuery Mobile移动应用实战》连载二(简单的QWER键盘)
  4. protobuf编译报错
  5. Java 图形编程 二:布局管理器之顺序布局
  6. Java 网络编程最佳实践(转载)
  7. (转)OpenGL中位图的操作(glReadPixels,glDrawPixels和glCopyPixels应用举例)
  8. 全景技术大揭秘,市场核心早洞悉——VR全景加盟
  9. KVM网页管理工具WebVirtMgr部署
  10. shell脚本中的整数测试
  11. Node.js 调试器
  12. Mybatis3.4.0不支持mybatis-spring1.2.5及以下版本
  13. 详解什么是平衡二叉树(AVL)(修订补充版)
  14. codeforces #541 F Asya And Kittens(并查集+输出路径)
  15. Centos6.8下编译安装LAMP的操作记录梳理
  16. Prezento – 轻量、简单的 jQuery 幻灯片插件
  17. 生成springboot docker镜像 并上传到阿里云镜像厂库
  18. ssh登录时在参数中加入密码的解决方案
  19. ubuntu 的chmod 和 chown
  20. CTF-练习平台-Misc之 又是一张图片,还单纯吗??

热门文章

  1. 解决This application failed to start because it could not find or load the Qt platform plugin &quot;windows
  2. DNS(转载)
  3. hdu 4176
  4. Emma中文乱码解决方法
  5. BZOJ 1787: [Ahoi2008]Meet 紧急集合(lca+贪心)
  6. THUSC2018 爆零记
  7. hdu 1025 n*logn最长上升子序列
  8. [AGC002D] Stamp Rally (并查集+整体二分)
  9. FckEditor2.65使用范例源码
  10. gridview行链接