我需要拆分一个字符串“Kermit D.Frogge”,所以这是我使用的代码:
firstName = strTkn.nextToken();
middleInitial = strTkn.nextToken(".");
//changing the delimiters to a . because there is no space between D and Frogge
lastName = strTkn.nextToken(" ");
//changing delimiters back to a space
hourlyWage = Double.parseDouble(strTkn.nextToken());
然而,结果是:
Kermit
D
.Frogge
我将如何使用字符串标记器而不保留句点?