{
int index, indexStart;
StringBuffer strDest = new StringBuffer(0);
int nOldLength = strOld.length();
if(nOldLength == 0)
return strSource;
index = strSource.indexOf(strOld);
if(index == -1)
return strSource;
strDest.append(strSource.substring(0, index)+strNew);
indexStart = index+nOldLength;
while((index = strSource.indexOf(strOld, indexStart)) != -1)
{
strDest.append(strSource.substring(indexStart, index)+strNew);
indexStart = index+nOldLength;
}
strDest.append(strSource.substring(indexStart));
return strDest.toString();
}
Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd
标签: