mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
More bug fixes - would throw a FileNotFound exception at startup if the $HOME/.grendel/grendel.pref file didn't exist. Now it creates it if it doesn't already exist.
This commit is contained in:
parent
ba5f073a74
commit
dcbed3ebf8
@ -27,6 +27,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.Properties;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Enumeration;
|
||||
@ -50,12 +51,21 @@ class PreferencesBase extends Properties implements Preferences {
|
||||
|
||||
File infile = new File(gPrefsPath, gPrefsFile);
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(infile);
|
||||
load(in);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (infile.exists() && infile.canRead() && infile.canWrite()) {
|
||||
try {
|
||||
in = new FileInputStream(infile);
|
||||
load(in);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
RandomAccessFile newPrefsFile = new RandomAccessFile(infile, "rw");
|
||||
newPrefsFile.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user