PlainTextByLineStream (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.util, class: PlainTextByLineStream

# Class PlainTextByLineStream

java.lang.Object
opennlp.tools.util.PlainTextByLineStream

All Implemented Interfaces:
  `AutoCloseable, ObjectStream<String>`

public class PlainTextByLineStream extends Object implements ObjectStream<String>
Reads a plain text file and returns each line as a `String` object.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PlainTextByLineStream(InputStreamFactory inputStreamFactory, String charsetName)`
  Initializes a `PlainTextByLineStream`.
  `PlainTextByLineStream(InputStreamFactory inputStreamFactory, Charset charset)`
  Initializes a `PlainTextByLineStream`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the `ObjectStream` and releases all allocated resources.
  `String`
  `read()`
  Returns the next `T` object.
  `void`
  `reset()`
  Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### PlainTextByLineStream

    public PlainTextByLineStream(InputStreamFactory inputStreamFactory, String charsetName) throws IOException
    Initializes a `PlainTextByLineStream`.
    Parameters:
      `inputStreamFactory` - The `InputStreamFactory` to use. Must not be `null`.
      `charsetName` - The name of the `Charset` that is used for interpreting characters.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### PlainTextByLineStream

    public PlainTextByLineStream(InputStreamFactory inputStreamFactory, Charset charset) throws IOException
    Initializes a `PlainTextByLineStream`.
    Parameters:
      `inputStreamFactory` - The `InputStreamFactory` to use. Must not be `null`.
      `charset` - The `Charset` that is used for interpreting characters.
    Throws:
      `IOException` - Thrown if IO errors occurred.

- ## Method Details

  - ### read

    public String read() throws IOException
    Description copied from interface: `ObjectStream`
    Returns the next `T` object. Calling this method repeatedly until it returns `null` will return each object from the underlying source exactly once.
    Specified by:
      `read` in interface `ObjectStream<String>`
    Returns:
      The next object or `null` to signal that the stream is exhausted.
    Throws:
      `IOException` - Thrown if there is an error during reading.

  - ### reset

    public void reset() throws IOException
    Description copied from interface: `ObjectStream`
    Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly. This method can be used to re-read the stream if multiple passes over the objects are required.

    The implementation of this method is optional.

    Specified by:
      `reset` in interface `ObjectStream<String>`
    Throws:
      `IOException` - Thrown if there is an error during resetting the stream.

  - ### close

    public void close() throws IOException
    Description copied from interface: `ObjectStream`
    Closes the `ObjectStream` and releases all allocated resources. After close was called, it's not allowed to call `ObjectStream.read()` or `ObjectStream.reset()`.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `ObjectStream<String>`
    Throws:
      `IOException` - Thrown if there is an error during closing the stream.