在Stringtokenizer中使用句点作为字符串分隔符

the*_*tna 0 java stringtokenizer

我想.从字符串标记中排除完全停止,如下例所示:

 I go to school.
Run Code Online (Sandbox Code Playgroud)

想生成令牌为:

        [ I] [go] [to] [school]
Run Code Online (Sandbox Code Playgroud)

我使用stringTokenizer作为:

List<String> listStr = new ArrayList<String>();
StringTokenizer strToken = new StringTokenizer(str);                    
int i =0;
while(strToken.hasMoreTokens()){
    listStr.add(i, strToken.nextToken());
    i=i+1;
}   
Run Code Online (Sandbox Code Playgroud)

但最后一个标志是school.我不想要的.我该怎么办?

ada*_*shr 5

这不是更简单吗?

List<String> list = Arrays.asList("I go to school.".split("[ .]"));
Run Code Online (Sandbox Code Playgroud)

System.out.println(list) 版画

[I, go, to, school]
Run Code Online (Sandbox Code Playgroud)