Store user preferences to a XML file just in case system preferences subsystem (e.g. Windows Registry) has issues
This commit is contained in:
parent
818c2ffcb1
commit
cc0c58070c
|
@ -194,6 +194,9 @@ public class Main {
|
||||||
HistorySpooler.getInstance().commit();
|
HistorySpooler.getInstance().commit();
|
||||||
SupportDialog.maybeShow();
|
SupportDialog.maybeShow();
|
||||||
|
|
||||||
|
// backup preferences on exit
|
||||||
|
Settings.store(ApplicationFolder.AppData.resolve("preferences.backup.xml"));
|
||||||
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,13 @@ package net.filebot;
|
||||||
|
|
||||||
import static net.filebot.Logging.*;
|
import static net.filebot.Logging.*;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -249,4 +256,20 @@ public final class Settings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void store(File f) {
|
||||||
|
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(f))) {
|
||||||
|
Preferences.userRoot().exportSubtree(out);
|
||||||
|
} catch (Exception e) {
|
||||||
|
debug.log(Level.SEVERE, e, e::toString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void restore(File f) {
|
||||||
|
try (InputStream in = new BufferedInputStream(new FileInputStream(f))) {
|
||||||
|
Preferences.importPreferences(in);
|
||||||
|
} catch (Exception e) {
|
||||||
|
debug.log(Level.SEVERE, e, e::toString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue