Created
July 13, 2015 23:08
-
-
Save ruoguluo/d1d1a9932c65eddf7701 to your computer and use it in GitHub Desktop.
getProperty from properties file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PropertyLoader { | |
private static Properties prop; | |
private PropertyLoader() { | |
} | |
public static synchronized String getProperty(String propertyName) throws IOException { | |
if (prop == null) { | |
prop = new Properties(); | |
InputStream in = PropertyLoader.class.getClassLoader().getResourceAsStream("local.properties"); | |
prop.load(in); | |
in.close(); | |
} | |
return (String) prop.get(propertyName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment