open class SimpleStringSplitter : MutableIterator<String!>, TextUtils.StringSplitter

A simple string splitter.

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 delimiter. That is, splitting "a,b," on comma will return "a", "b", not "a", "b", "".

Summary

Public constructors

Initializes the splitter.

Public methods
open Boolean

hasNext()

Returns true if the iteration has more elements.

open MutableIterator<String!>

iterator()

Returns an iterator over elements of type T.

open String!

next()

Returns the next element in the iteration.

open Unit

remove()

Removes from the underlying collection the last element returned by this iterator (optional operation).

open Unit

setString(string: String!)

Sets the string to split

Public constructors

SimpleStringSplitter

SimpleStringSplitter(delimiter: Char)

Initializes the splitter. setString may be called later.

Parameters
delimiter Char: the delimiter on which to split

Public methods

hasNext

open fun hasNext(): Boolean

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Return
Boolean true if the iteration has more elements

next

open fun next(): String!

Returns the next element in the iteration.

Return
String! the next element in the iteration
Exceptions
java.util.NoSuchElementException if the iteration has no more elements

remove

open fun remove(): Unit

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to 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, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Exceptions
java.lang.IllegalStateException if the next method has not yet been called, or the remove method has already been called after the last call to the next method
java.lang.UnsupportedOperationException if the remove operation is not supported by this iterator

setString

open fun setString(string: String!): Unit

Sets the string to split

Parameters
string String!: the string to split

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-02-13 UTC.