Posted By

spupy on 02/04/12


Tagged

properties


Versions (?)

Get String from file-backed Properties


 / Published in: Java
 

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

  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  

You need to login to post a comment.