java读取配置文件.properties属性值

属性文件.properies:

Properties properties = FooUtil.read("/file.properties");

<pre name="code" class="java">public class FooUtil {
	private static final Map<String, Properties> map = new HashMap<String, Properties>();
	  
	  public static Properties read(String path)
	    throws IOException
	  {
	    Properties properties = (Properties)map.get(path);
	    if (properties == null)
	    {
	      properties = new Properties();
	      properties.load(FooUtil.class.getResourceAsStream(path));
	      map.put(path, properties);
	    }
	    return properties;
	  }
}


 
 

猜你喜欢

转载自blog.csdn.net/caisenbinbeida2009/article/details/41443531