String截取
1.str.substring(start,end)
end可以省略
eg
1.取字符串的前i个字符:str=str.Substring(0,i);
2.去掉字符串的前i个字符str=str.Substring(i)
2.replaceAll(resource,result)
支持正则
eg
String spec = "IP:".concat(sourceIp.replaceAll(":",":PORT").replaceAll(";:",";IP"));
3.String string2 = string.replace("old","new");
4.Object--json--String
List<DeptDTO> list = (List<DeptDTO>)result.getResData().get("list");
//list-->jsonArry
JSONArray jsonArray= JSONArray.parseArray(JSON.toJSONString(list));
//jsonArry-->String
String string = jsonArray.toJSONString();
String string2 = string.replace("childDeptList","childrenDeptList");
//String-->jsonArry
jsonArray= JSONArray.parseArray(string2);
//jsonArry-->list
List<DeptDTO2> list2 = JSONObject.parseArray(jsonArray.toJSONString(), DeptDTO2.class);