TextUtils.SimpleStringSplitter

  • TextUtils.SimpleStringSplitter is a utility class in Android for splitting strings based on a delimiter.

  • It provides methods like hasNext(), next(), and setString() to iterate through the split parts of the string.

  • If the string ends with the delimiter, it does not return an empty string at the end.

  • The SimpleStringSplitter is initialized with the delimiter character and the string to be split is set using setString().

public static class TextUtils.SimpleStringSplitter extends Object
implements TextUtils.StringSplitter Iterator<String>

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

Public Constructor Summary

SimpleStringSplitter(char delimiter)
Initializes the splitter.

Public Method Summary

boolean
Iterator<String>
String
next()
void
remove()
void
setString(String string)
Sets the string to split

Inherited Method Summary

Public Constructors

public SimpleStringSplitter (char delimiter)

Initializes the splitter. setString may be called later.

Parameters
delimiter the delimeter on which to split

Public Methods

public boolean hasNext ()

public Iterator<String> iterator ()

public String next ()

public void remove ()

public void setString (String string)

Sets the string to split

Parameters
string the string to split