從配置文件獲取數據

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

 

 

public class PropertyMgr {
static Properties props = new Properties();
 
 static {
  try {
        props.load(PropertyMgr.class.getClassLoader().getResourceAsStream("1.properties"));
      } catch (IOException e1) {
          e1.printStackTrace();
     }
 }
 
 private PropertyMgr() {};


  public static String getProperty(String key) {
  

            return props.getProperty(key);
 }


}

 

1.properties:initTankCount=10
                      reProduceTankCount=3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章