public String replace(String parentStr,String ch,String rep) { int i = parentStr.indexOf(ch); StringBuffer sb = new StringBuffer(); if (i == -1) return parentStr; sb.append(parentStr.substring(0,i) + rep); if (i+ch.length() < parentStr.length()) sb.append(replace(parentStr.substring(i+ch.length(),parentStr.length()),ch,rep)); return sb.toString(); }
split ****************************** import java.util.StringTokenizer; ......... StringTokenizer stTemp = new StringTokenizer("this is a string"," ");//" "是空格 String[] b = new String[5]; int mIntCount = 0; while(stTemp.hasMoreTokens()) { try { b[mIntCount] = stTemp.nextToken(); System.out.println(b[mIntCount]); mIntCount++; } catch(Exception e1) {
是对数据流进行处理
你若是要的话,我发给你。
email:[email protected]
int i = parentStr.indexOf(ch);
StringBuffer sb = new StringBuffer();
if (i == -1)
return parentStr;
sb.append(parentStr.substring(0,i) + rep);
if (i+ch.length() < parentStr.length())
sb.append(replace(parentStr.substring(i+ch.length(),parentStr.length()),ch,rep));
return sb.toString();
}
******************************
import java.util.StringTokenizer;
......... StringTokenizer stTemp = new StringTokenizer("this is a string"," ");//" "是空格
String[] b = new String[5];
int mIntCount = 0;
while(stTemp.hasMoreTokens())
{
try
{
b[mIntCount] = stTemp.nextToken();
System.out.println(b[mIntCount]);
mIntCount++;
}
catch(Exception e1)
{
}
}