读取properties文件

//this.getClass().getClassLoader().getResource("/").getPath();代表class的路径

例如:/usr/local/apache-publish/apache-tomcat-5.5.26/webapps/integralGame/WEB-INF/classes/

File file = new File(this.getClass().getClassLoader().getResource("/").getPath()                                  +"Environment.properties");
   Properties properties = new Properties();
   properties.load(new FileInputStream(file));
   String url = properties.getProperty("url");
       
   System.out.println("url:   "+url);

 

 

你可能感兴趣的:(apache,tomcat,Web)