ConfigWriter (JHOVE Documentation)
Date: 2012-10-21

edu.harvard.hul.ois.jhove.viewer

## Class ConfigWriter

- java.lang.Object
- - edu.harvard.hul.ois.jhove.viewer.ConfigWriter

-     public class ConfigWriter
      extends java.lang.Object

  Class to write out configuration information to the configuration file. To minimize the chance of getting into a bad state, it writes to a temporary file, then replaces the old config file with that file, rather than directly overwriting the existing file.
  Author:
    Gary McGath

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ConfigWriter.ModuleInfo`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConfigWriter(java.io.File file, ConfigWindow parent)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `writeFile(java.util.List<ConfigWriter.ModuleInfo> modules, java.util.List<java.lang.String> handlers, java.io.File homeDir, java.io.File tempDir, java.lang.String encoding, int bufferSize)` Writes out the content of the file to the temporary file, then deletes the existing configuration file (as specified by the constructor parameter) and renames the temporary file to the configuration file.

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

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

- - ### Constructor Detail

    - #### ConfigWriter

          public ConfigWriter(java.io.File file,
                      ConfigWindow parent)
                       throws java.io.IOException

      Constructor. Creates a temporary file for writing and creates an OutputStreamWriter to write to it. If there is already a file located by `file`, it will not be replaced or overwritten until `writeFile` has successfully written out the temporary file.
      Parameters:
        `file` - Location of the configuration file
        `parent` - The ConfigWindow which invoked this instance. May be null if invoked to write a default config file.
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### writeFile

          public void writeFile(java.util.List<ConfigWriter.ModuleInfo> modules,
                       java.util.List<java.lang.String> handlers,
                       java.io.File homeDir,
                       java.io.File tempDir,
                       java.lang.String encoding,
                       int bufferSize)
                         throws java.io.IOException

      Writes out the content of the file to the temporary file, then deletes the existing configuration file (as specified by the constructor parameter) and renames the temporary file to the configuration file. If the temporary file can't be written, or the configuration file can't be replaced, a warning dialog is put up and the configuration file remains unchanged.
      Throws:
        `java.io.IOException`