get key and value from properties file in different location, ratherthan current source directory
/**
* it receive the property value for the tree view preference.
* @param key
* @return
*/
public static String getPluginProperty(String key, String file) {
String str = null;
FileInputStream fis=null;
try {
Properties p = new Properties();
if(file.isEmpty()) {
fis = new FileInputStream(PLUGIN_NAME);
}else {
fis = new FileInputStream(file);
}
p.load(fis);
str = p.getProperty(key);
} catch (Exception s) {
}
return str;
}
/**
* gives all property keys from the properties file
*/
public static void getPreferenceValues() {
ResourceBundle preferenceBundle = null;
FileInputStream fis;
File filename=new File(System.getProperty("user.home")+ "\\mmsb\\mmsb_preference.properties");
try {
if(filename.exists()) {
fis = new FileInputStream(filename);
}else {
return ;
}
preferenceBundle = new PropertyResourceBundle(fis);
Set keys=preferenceBundle.keySet();
preferenceMap=new HashMap();
for(String key:keys) {
String value=preferenceBundle.getString(key);
if(value==null) {
value="";
}
preferenceMap.put(key,value);
}
}catch(Exception e) {
System.err.println("error at reading preference file.");
}
}
Comments