get Properties - Java java.util

Java examples for java.util:Properties File

Description

get Properties

Demo Code


import java.io.IOException;
import java.util.Properties;

public class Main{
    private static final Object LOCK = new Object();
    private static Properties props = null;
    public final static Properties getProperties(){
      if(props == null){
         synchronized (LOCK) {
            setProperties();/*from   w  w  w.j  av a2 s  .  com*/
         }
      }
      return props;
   }
    private final static void setProperties(){
      props = new Properties();
      try {
         props.load(Main.class.getResourceAsStream("/server/config/server.properties"));
      } catch (IOException e) {
         props = null;
         e.printStackTrace();
      }
   }
}

Related Tutorials