当前位置: 代码迷 >> Web前端 >> 读取配置文件(寄放固定值)
  详细解决方案

读取配置文件(寄放固定值)

热度:176   发布时间:2012-11-04 10:42:41.0
读取配置文件(存放固定值)

读取:

public class PropertiesConfig {
  private static Properties prop;
  static
   {
      prop = new Properties();
      // 从属性配置文件中读取配置参数
      try
      {
        InputStream resource = PropertiesConfig.class.getResourceAsStream("/db.conf");
         System.out.println(resource);
         prop.load(resource);
         resource.close();
      } catch (java.io.IOException e)
      {
         e.printStackTrace();
         System.out.println("Could not read list of ages");
      }
   }
   /**
    *
    * @返回参数属性集
    */
   public Properties getProperties(){
     return prop;
   }}

?

2.调用:

private String userNaming ;
	public Show_Areainfo(){
		Properties prop=new PropertiesConfig().getProperties();
		userNaming=prop.get("service").toString();
	}

?

?929wyt.com? http://se.sao49.com/

?

?

  相关解决方案