구성 파일 읽기(고정 값 저장)

1130 단어 구성 파일 읽기
읽기:
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/
 

좋은 웹페이지 즐겨찾기