SSISO Community

시소당

Properties file은 어떤 경우에 쓰나요?

Properties  file을  써서  과제를  내라는데  뭘  어떻게  쓰라는지  이해가  잘  안갑니다.
어떤경우데  Properties  file을  주로  쓰나요?  왜  쓰는지도  궁금합니다.
예제  있으면  올려주실수  있을까요?
감사합니다.!!

------------------------------------------------------------------------------------------



info.property  라는  파일에  이런  내용이  있다고  가정하면
#  환경설정  파일입니다
NAME=booler
ADDRESS=Seoul  

소스를  보시면  NAME과  ADDRESS의  값을  쉽게  구할수  있습니다

    String  propertyFile  =  "info.property";
    Properties  ppt  =  new  Properties();
    try  {
      ppt.load(new  FileInputStream(propertyFile));
    }  catch  (FileNotFoundException  e)  {
      e.printStackTrace();
    }  catch  (IOException  e)  {
      e.printStackTrace();
    }

    String  name  =  ppt.getProperty("NAME");
    String  addr  =  ppt.getProperty("ADDRESS");

이상입니다.

696 view

4.0 stars