仅代码,暂无实例
/**
* 计算子字符串出现的次数
*
* @param parentStr
* @param childStr
* @return
*/
public static int getChildStrCounts(String parentStr, String childStr) {
int propsIndex = 0;
int counts = 0; // properties 出现几次代表字段嵌套几层
while (parentStr.indexOf(childStr, propsIndex) != -1) {
counts++;
propsIndex = parentStr.indexOf(childStr, propsIndex) + childStr.length();
}
return counts;
}