Devel/RCP(Rich Client Platform)
eclipse plug-in RCP 프로젝트 resources 폴더 추가와 파일 읽기
kogun82
2020. 7. 31. 11:28
plug-in RCP 프로젝트에 resources 폴더를 추가한다.
생성한 resources 폴더를 classpath에 설정한다.
아래의 코드와 같이 추가한 classpath에 추가된 데이터 파일을 읽을 수 있다.
URL url = this.getClass().getClassLoader().getResource("resources");
try {
String resourcesPath = FileLocator.toFileURL(url).getPath() + "/application.conf";
String conf = FileUtils.readFileToString(new File(resourcesPath));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
반응형