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

opennlp.tools.ml.perceptron

## Class BinaryPerceptronModelWriter

- java.lang.Object
- - opennlp.tools.ml.model.AbstractModelWriter
  - - opennlp.tools.ml.perceptron.PerceptronModelWriter
    - - opennlp.tools.ml.perceptron.BinaryPerceptronModelWriter

-     public class BinaryPerceptronModelWriter
      extends PerceptronModelWriter

  Model writer that saves models in binary format.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BinaryPerceptronModelWriter(AbstractModel model, DataOutputStream dos)` Constructor which takes a GISModel and a DataOutputStream and prepares itself to write the model to that stream.
    `BinaryPerceptronModelWriter(AbstractModel model, File f)` Constructor which takes a GISModel and a File and prepares itself to write the model to that file.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `writeDouble(double d)`
    `void` | `writeInt(int i)`
    `void` | `writeUTF(String s)`

    - ### Methods inherited from class opennlp.tools.ml.perceptron.PerceptronModelWriter

      `persist`

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

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

- - ### Constructor Detail

    - #### BinaryPerceptronModelWriter

          public BinaryPerceptronModelWriter(AbstractModel model,
                                             File f)
                                      throws IOException

      Constructor which takes a GISModel and a File and prepares itself to write the model to that file. Detects whether the file is gzipped or not based on whether the suffix contains ".gz".
      Parameters:
        `model` - The GISModel which is to be persisted.
        `f` - The File in which the model is to be persisted.
      Throws:
        `IOException`

    - #### BinaryPerceptronModelWriter

          public BinaryPerceptronModelWriter(AbstractModel model,
                                             DataOutputStream dos)

      Constructor which takes a GISModel and a DataOutputStream and prepares itself to write the model to that stream.
      Parameters:
        `model` - The GISModel which is to be persisted.
        `dos` - The stream which will be used to persist the model.

  - ### Method Detail

    - #### writeUTF

          public void writeUTF(String s)
                        throws IOException

      Specified by:
        `writeUTF` in class `AbstractModelWriter`
      Throws:
        `IOException`

    - #### writeInt

          public void writeInt(int i)
                        throws IOException

      Specified by:
        `writeInt` in class `AbstractModelWriter`
      Throws:
        `IOException`

    - #### writeDouble

          public void writeDouble(double d)
                           throws IOException

      Specified by:
        `writeDouble` in class `AbstractModelWriter`
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in class `AbstractModelWriter`
      Throws:
        `IOException`

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