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:
talisman%anamorphic.com 1999-06-16 05:15:31 +00:00
parent ba5f073a74
commit dcbed3ebf8

View File

@ -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();
}
}
}