Get String from file-backed Properties


/ Published in: Java
Save to your folder(s)

Loads Properties from a file and retrieves a single String property.


Copy this code and paste it in your HTML
  1. private static Properties properties;
  2.  
  3. private static String getProp(String propKey) {
  4. if (properties == null) {
  5. properties = new Properties();
  6. try {
  7. properties.load(new FileInputStream("myprops.config"));
  8. } catch (IOException e) {
  9. }
  10. }
  11. return properties.getProperty(propKey);
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.