Skip to content

Instantly share code, notes, and snippets.

@hmenn
Created February 1, 2017 22:45
Show Gist options
  • Save hmenn/75e79941e7918d5539def89814325450 to your computer and use it in GitHub Desktop.
Save hmenn/75e79941e7918d5539def89814325450 to your computer and use it in GitHub Desktop.
read properties file in Java
public Properties getPropertiesFromFile(String fileName) {
Properties properties = null;
try {
properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream(fileName));
} catch (IOException e) {
System.err.println("Error detected");
e.printStackTrace();
}
return properties;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment