Class ConfigWriter

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

public class ConfigWriter extends 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
  • Constructor Details

    • ConfigWriter

      public ConfigWriter(File file, ConfigWindow parent) throws 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:
      IOException
  • Method Details

    • writeFile

      public void writeFile(List<ModuleInfo> modules, List<String[]> handlers, File homeDir, File tempDir, 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. 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.