Package edu.harvard.hul.ois.jhove
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 Summary
Constructors Constructor Description ConfigWriter(File file, ConfigWindow parent)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidwriteFile(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.
-
-
-
Constructor Detail
-
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 byfile, it will not be replaced or overwritten untilwriteFilehas successfully written out the temporary file.- Parameters:
file- Location of the configuration fileparent- The ConfigWindow which invoked this instance. May be null if invoked to write a default config file.- Throws:
IOException
-
-
Method Detail
-
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.
-
-