我有类似的字符串"align is going to school sad may me"
。我想在四个空格之后获取子字符串。字符串将在运行时输入。任何人都可以建议我在一些空格后找到子字符串......
String st = "align is going to school sad may me";
int i = 0;
String [] strings = new String [15];
StringTokenizer stringTokenizer = new StringTokenizer (st, " ");
while (stringTokenizer.hasMoreElements ())
{
strings [i]= (String)stringTokenizer.nextElement ();
i++;
}
System.out.println ("I value is" + i);
for (int j=4; j<i; j++)
{
System.out.print (strings[j] + " ");
}
我已经尝试过这个并且它正在工作,您能否建议我在一些空格后找到 Sub 字符串的简单方法。