Created
January 12, 2016 23:15
-
-
Save ssinganamalla/b00da073da999f290ef4 to your computer and use it in GitHub Desktop.
Load config properties file located in resources directory
This file contains 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 static ApplicationProperties loadProperties() { | |
Properties prop = new Properties(); | |
InputStream input = null; | |
try { | |
ClassLoader classloader = Thread.currentThread().getContextClassLoader(); | |
input = classloader.getResourceAsStream("config.properties"); | |
// load a properties file | |
prop.load(input); | |
} catch (IOException ex) { | |
ex.printStackTrace(); | |
} finally { | |
if (input != null) { | |
try { | |
input.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
return new ApplicationProperties(prop); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment