public static class TextUtils.SimpleStringSplitter extends Object implements TextUtils.StringSplitter, Iterator<String>
If the final character in the string to split is the delimiter then no empty string will be returned for the empty string after that delimeter. That is, splitting "a,b," on comma will return "a", "b", not "a", "b", "".
Constructor and Description |
---|
SimpleStringSplitter(char delimiter)
Initializes the splitter. setString may be called later.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Returns
true if the iteration has more elements. |
Iterator<String> |
iterator()
Returns an iterator over elements of type
T . |
String |
next()
Returns the next element in the iteration.
|
void |
remove()
Removes from the underlying collection the last element returned
by this iterator (optional operation).
|
void |
setString(String string)
Sets the string to split
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
forEachRemaining
public SimpleStringSplitter(char delimiter)
delimiter
- the delimeter on which to splitpublic void setString(String string)
setString
in interface TextUtils.StringSplitter
string
- the string to splitpublic Iterator<String> iterator()
Iterable
T
.public boolean hasNext()
Iterator
true
if the iteration has more elements.
(In other words, returns true
if Iterator.next()
would
return an element rather than throwing an exception.)public String next()
Iterator
public void remove()
Iterator
Iterator.next()
. The behavior of an iterator
is unspecified if the underlying collection is modified while the
iteration is in progress in any way other than by calling this
method.