SW개발/Java

Properties 위치 / java.io.IOException: java.io.FileNotFoundException: XXXX.properties (지정된 파일을 찾을 수 없습니다)

개소왕 2019. 6. 6. 16:29

* 개요

Properties 사용시 

 

java.io.IOException: java.io.FileNotFoundException: air.properties (지정된 파일을 찾을 수 없습니다)

 

 

 

 

* 해결

FileInputStream fis = new FileInputStream(fileName);

을 다음으로 대체


getClass().getResourceAsStream(fileName));

 

 

properties 파일이 java 파일과 같은 폴더에 있고 파일명만 명시한다면

FileInputStream 이 아니라 getClass()... 에서 가져와야 .. 

 

https://stackoverflow.com/questions/6696583/path-of-properties-file-in-java