java - Accessing getProperty() outside of class -
public static properties defaultprops = new properties(); static { try { fileinputstream in = new fileinputstream("config.properties"); defaultprops.load(in); in.close(); } catch (exception e) { e.printstacktrace(); } } public static string getproperty(string database) { return defaultprops.getproperty(database); } public static void main(string[] args) { system.out.println(...key database?); // part try test if can print property 'database' // try make available other classes, tried using public statics, } this code in retrieve properties properties file config.properties. however, want able print property n (here: database) , able use property n in other classes.
thanks in advance.
so call
system.out.println(getproperty("database"));
Comments
Post a Comment