Returns the next token in the string as a String. @return next token in the string as a String. @throws NoSuchElementException if no tokens remain.
()
| 243 | * if no tokens remain. |
| 244 | */ |
| 245 | public String nextToken() { |
| 246 | if (delimiters == null) { |
| 247 | throw new NullPointerException(); |
| 248 | } |
| 249 | int i = position; |
| 250 | int length = string.length(); |
| 251 | |
| 252 | if (i < length) { |
| 253 | if (returnDelimiters) { |
| 254 | if (delimiters.indexOf(string.charAt(position), 0) >= 0) |
| 255 | return String.valueOf(string.charAt(position++)); |
| 256 | for (position++; position < length; position++) |
| 257 | if (delimiters.indexOf(string.charAt(position), 0) >= 0) |
| 258 | return string.substring(i, position); |
| 259 | return string.substring(i); |
| 260 | } |
| 261 | |
| 262 | while (i < length && delimiters.indexOf(string.charAt(i), 0) >= 0) |
| 263 | i++; |
| 264 | position = i; |
| 265 | if (i < length) { |
| 266 | for (position++; position < length; position++) |
| 267 | if (delimiters.indexOf(string.charAt(position), 0) >= 0) |
| 268 | return string.substring(i, position); |
| 269 | return string.substring(i); |
| 270 | } |
| 271 | } |
| 272 | throw new NoSuchElementException(); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Returns the next token in the string as a {@code String}. The delimiters |