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

# Class DownloadUtil

java.lang.Object
opennlp.tools.util.DownloadUtil

public class DownloadUtil extends Object
This class facilitates the downloading of pretrained OpenNLP models.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DownloadUtil()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T extends BaseModel>
  T`
  `downloadModel(String language, ModelType modelType, Class<T> type)`
  Triggers a download for the specified `ModelType`.
  `static <T extends BaseModel>
  T`
  `downloadModel(URL url, Class<T> type)`
  Downloads a model from a `URL`.
  `static Map<String, Map<ModelType, String>>`
  `getAvailableModels()`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### DownloadUtil

    public DownloadUtil()

- ## Method Details

  - ### downloadModel

    public static <T extends BaseModel> T downloadModel(String language, ModelType modelType, Class<T> type) throws IOException
    Triggers a download for the specified `ModelType`.
    Type Parameters:
      `T` - The generic type which is a subclass of `BaseModel`.
    Parameters:
      `language` - The ISO language code of the requested model.
      `modelType` - The `type` of model.
      `type` - The class of the resulting model.
    Returns:
      A model instance of type `T`.
    Throws:
      `IOException` - Thrown if IO errors occurred or the model is invalid.

  - ### downloadModel

    public static <T extends BaseModel> T downloadModel(URL url, Class<T> type) throws IOException
    Downloads a model from a `URL`.

    The model is saved to an `.opennlp/` directory located in the user's home directory. This directory will be created if it does not already exist. If a model to be downloaded already exists in that directory, the model will not be re-downloaded.

    Type Parameters:
      `T` - The generic type which is a subclass of `BaseModel`.
    Parameters:
      `url` - The model's `URL`.
      `type` - The class of the resulting model `T`.
    Returns:
      A model instance of type `T`.
    Throws:
      `IOException` - Thrown if the model cannot be downloaded.

  - ### getAvailableModels

    public static Map<String, Map<ModelType, String>> getAvailableModels()