ClassLoader를 사용하여 Properties 클래스의 속성 파일을로드하려고합니다. 나는 "theta.properties"파일이이 클래스와 같은 디렉토리에서Java ClassLoader를 사용하여 클래스 경로에서 파일을로드하는 방법은 무엇입니까?
loader = this.getClass().getClassLoader();
in = loader.getResourceAsStream("theta.properties");
result = new Properties();
result.load(in);
를하지만의 InputStream는 항상 null의 :이 토론의 목적을 위해 처리 오류를 제거하려면 아래의 코드를 단순화했습니다. 파일을 틀린 장소에두고 있습니까? 이클립스와 그 세트를 사용하여 클래스 파일을 소스 폴더에 빌드하므로 문제가되지 않아야합니다.
JavaDoc에서 ClassLoader가 어떤 클래스 경로를 검색하는지 알 수없는 항목이 있습니다.