Package org.apache.commons.lang3.util

# Class IterableStringTokenizer

java.lang.Object
java.util.StringTokenizer
org.apache.commons.lang3.util.IterableStringTokenizer

All Implemented Interfaces:
  `Iterable<String>`, `Enumeration<Object>`

public class IterableStringTokenizer extends StringTokenizer implements Iterable<String>
A `StringTokenizer` that implements `Iterable``<String>` and conversion methods `toList()` and `toStream()`.

Since:
  3.18.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IterableStringTokenizer(String str)`
  Constructs a new instance like `StringTokenizer(String, String, boolean)`.
  `IterableStringTokenizer(String str, String delim)`
  Constructs a new instance like `StringTokenizer(String, String, boolean)`.
  `IterableStringTokenizer(String str, String delim, boolean returnDelims)`
  Constructs a new instance like `StringTokenizer(String, String, boolean)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Iterator<String>`
  `iterator()`
  `String[]`
  `toArray()`
  Returns a new `String[]` containing the tokenizer elements.
  `List<String>`
  `toList()`
  Returns a new `List` containing the tokenizer elements.
  `Stream<String>`
  `toStream()`
  Returns a sequential stream on this Iterable instance.

  ### Methods inherited from class java.util.StringTokenizer

  `countTokens, hasMoreElements, hasMoreTokens, nextElement, nextToken, nextToken`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### IterableStringTokenizer

    public IterableStringTokenizer(String str)
    Constructs a new instance like `StringTokenizer(String, String, boolean)`.
    Parameters:
      `str` - a string to be parsed.
    Throws:
      `NullPointerException` - if str is `null`.

  - ### IterableStringTokenizer

    public IterableStringTokenizer(String str, String delim)
    Constructs a new instance like `StringTokenizer(String, String, boolean)`.
    Parameters:
      `str` - a string to be parsed.
      `delim` - the delimiters.
    Throws:
      `NullPointerException` - if str is `null`.

  - ### IterableStringTokenizer

    public IterableStringTokenizer(String str, String delim, boolean returnDelims)
    Constructs a new instance like `StringTokenizer(String, String, boolean)`.
    Parameters:
      `str` - a string to be parsed.
      `delim` - the delimiters.
      `returnDelims` - flag indicating whether to return the delimiters as tokens.
    Throws:
      `NullPointerException` - if str is `null`.

- ## Method Details

  - ### iterator

    public Iterator<String> iterator()
    Specified by:
      `iterator` in interface `Iterable<String>`

  - ### toArray

    public String[] toArray()
    Returns a new `String[]` containing the tokenizer elements.
    Returns:
      a new `String[]`.

  - ### toList

    public List<String> toList()
    Returns a new `List` containing the tokenizer elements.
    Returns:
      a new `List`.

  - ### toStream

    public Stream<String> toStream()
    Returns a sequential stream on this Iterable instance.
    Returns:
      a sequential stream on this Iterable instance.