2014-01-15 2 views
0

java의 web-inf 폴더에있는 .properties 파일에 액세스하려고 시도하고 있지만 어떻게해야하는지 알 수 없습니다.WEB-INF | Java

파일에 액세스 할 수없는 경우 그 이유는 무엇입니까?

그러나 패키지 내부의 파일에 액세스 할 수 있습니다. 그 코드는 다음과 같습니다 :

Properties prop = new Properties(); 
     InputStream in = ReadPropertyFile.class.getResourceAsStream("temp.properties"); 
     prop.load(in); 
     System.out.println(prop.getProperty("asd")); 
     in.close(); 

그럼 어떻게 자바 클래스 안에서 이것을 할 수 있을까요?

+0

은 등록 정보 파일의 전체 경로를 사용합니다. – Rahul

+0

예. WEB-INF/temp.properties..it가 널 포인터를 던지고 있습니다. – sree

+0

이 경로를'/ yourappname/web-inf /'로 바꾸십시오. –

답변

2

아래 코드를 사용해 보았습니다.

 Properties prop = new Properties(); 
     prop.load(new FileInputStream("./WebContent/WEB-INF/my.properties")); 
     System.out.println(prop.getProperty("data")); 

입니다.

+0

옙 ..thanks vinayak..its working – sree