GenericModelWriter (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.ml.model, class: GenericModelWriter

# Class GenericModelWriter

java.lang.Object
opennlp.tools.ml.model.AbstractModelWriter
opennlp.tools.ml.model.GenericModelWriter

public class GenericModelWriter extends AbstractModelWriter
An generic `AbstractModelWriter` implementation.

See Also:
  - `AbstractModelWriter`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GenericModelWriter(AbstractModel model, DataOutputStream dos)`
  Initializes a `GenericModelWriter` for an `AbstractModel` with an associated `DataOutputStream` the model shall be written to.
  `GenericModelWriter(AbstractModel model, File file)`
  Initializes a `GenericModelWriter` for an `AbstractModel` with an associated `File` the model shall be written to.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the underlying `DataOutputStream`.
  `void`
  `persist()`
  Serializes the `model` using the `AbstractModelWriter.writeUTF(String)`, `AbstractModelWriter.writeDouble(double)`, or `AbstractModelWriter.writeInt(int)`} methods implemented by extending classes.
  `void`
  `writeDouble(double d)`
  Writes a single `double` to the underlying `DataOutputStream`.
  `void`
  `writeInt(int i)`
  Writes a single `int` to the underlying `DataOutputStream`.
  `void`
  `writeUTF(String s)`
  Writes a `String` to the underlying `DataOutputStream`.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### GenericModelWriter

    public GenericModelWriter(AbstractModel model, File file) throws IOException
    Initializes a `GenericModelWriter` for an `AbstractModel` with an associated `File` the model shall be written to.
    Parameters:
      `model` - The `model` to write out.
      `file` - The `File` that used to be written to.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### GenericModelWriter

    public GenericModelWriter(AbstractModel model, DataOutputStream dos)
    Initializes a `GenericModelWriter` for an `AbstractModel` with an associated `DataOutputStream` the model shall be written to.
    Parameters:
      `model` - The `model` to write out.
      `dos` - The `DataOutputStream` that used to be written to.

- ## Method Details

  - ### close

    public void close() throws IOException
    Description copied from class: `AbstractModelWriter`
    Closes the underlying `DataOutputStream`.
    Specified by:
      `close` in class `AbstractModelWriter`
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### persist

    public void persist() throws IOException
    Description copied from class: `AbstractModelWriter`
    Serializes the `model` using the `AbstractModelWriter.writeUTF(String)`, `AbstractModelWriter.writeDouble(double)`, or `AbstractModelWriter.writeInt(int)`} methods implemented by extending classes.
    Specified by:
      `persist` in class `AbstractModelWriter`
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### writeDouble

    public void writeDouble(double d) throws IOException
    Description copied from class: `AbstractModelWriter`
    Writes a single `double` to the underlying `DataOutputStream`.
    Specified by:
      `writeDouble` in class `AbstractModelWriter`
    Parameters:
      `d` - The `double` value.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### writeInt

    public void writeInt(int i) throws IOException
    Description copied from class: `AbstractModelWriter`
    Writes a single `int` to the underlying `DataOutputStream`.
    Specified by:
      `writeInt` in class `AbstractModelWriter`
    Parameters:
      `i` - The `int` value.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### writeUTF

    public void writeUTF(String s) throws IOException
    Description copied from class: `AbstractModelWriter`
    Writes a `String` to the underlying `DataOutputStream`.
    Specified by:
      `writeUTF` in class `AbstractModelWriter`
    Parameters:
      `s` - The `UTF encoded` characters.
    Throws:
      `IOException` - Thrown if IO errors occurred.