배우기

ClassLoader.getSystemResource 사용해서 property 파일 읽기

우썅 2014. 2. 24. 17:03

property 파일을 CLASSPATH 에 넣고 ClassLoader.getSystemResource 를 사용해서 불러올 때

property 파일의 위치가 패키지 않에 있다면 package 명 까지 정확하게 적어줘야 한다.


당연한데 나만 몰랐나...


Properties prop = new Properties();


try

{

   prop.load(ClassLoader.getSystemResource("org/redgura/property/conifg.properties").openStream());

}

catch (IOException e)

{

   e.printStackTrace();

}


String time = prop.getProperty("TIME");