TokenSampleStream (Apache OpenNLP Tools 1.9.5 API)
Date: 2026-06-18

opennlp.tools.tokenize.lang.en

## Class TokenSampleStream

- java.lang.Object
- - opennlp.tools.tokenize.lang.en.TokenSampleStream

- All Implemented Interfaces:
    Iterator<TokenSample>

      public class TokenSampleStream
      extends Object
      implements Iterator<TokenSample>

  Class which produces an Iterator<TokenSample> from a file of space delimited token. This class uses a number of English-specific heuristics to un-separate tokens which are typically found together in text.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TokenSampleStream(InputStream is)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `hasNext()`
    `TokenSample` | `next()`
    `void` | `remove()`

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

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

    - ### Methods inherited from interface java.util.Iterator

      `forEachRemaining`

- - ### Constructor Detail

    - #### TokenSampleStream

          public TokenSampleStream(InputStream is)
                            throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### hasNext

          public boolean hasNext()

      Specified by:
        `hasNext` in interface `Iterator<TokenSample>`

    - #### next

          public TokenSample next()

      Specified by:
        `next` in interface `Iterator<TokenSample>`

    - #### remove

          public void remove()

      Specified by:
        `remove` in interface `Iterator<TokenSample>`

Copyright © 2026 The Apache Software Foundation. All rights reserved.