2 import java
.io
.FileReader
;
3 import java
.io
.FileInputStream
;
4 import java
.io
.FileOutputStream
;
5 import java
.util
.Properties
;
7 /** Load from and save options into a file.
12 static public Options
Instance ()
14 if (saOptions
== null)
15 saOptions
= new Options ();
19 static public void SetString (String sName
, String sValue
)
21 Instance().setProperty (sName
, sValue
);
24 static public String
GetString (String sName
)
26 return Instance().getProperty (sName
);
29 static public void SetBoolean (String sName
, boolean bValue
)
31 Instance().setProperty (sName
, Boolean
.toString(bValue
));
34 static public boolean GetBoolean (String sName
)
36 return Boolean
.getBoolean(Instance().getProperty (sName
));
39 static public void SetInteger (String sName
, int nValue
)
41 Instance().setProperty (sName
, Integer
.toString(nValue
));
44 static public int GetInteger (String sName
, int nDefault
)
46 String sValue
= Instance().getProperty (sName
);
50 return Integer
.parseInt (sValue
);
53 public void Load (String sBaseName
)
57 load (new FileInputStream (ProvideFile(sBaseName
)));
59 catch (java
.io
.IOException e
)
61 // Ignore a non-existing options file.
65 public void Save (String sBaseName
)
69 store (new FileOutputStream (ProvideFile(sBaseName
)), null);
71 catch (java
.io
.IOException e
)
80 private File
ProvideFile (String sBaseName
)
83 System
.getProperty ("user.home"),
87 static private Options saOptions
= null;