새소식

Devel/RCP(Rich Client Platform)

eclipse plug-in RCP 프로젝트 resources 폴더 추가와 파일 읽기

  • -

plug-in RCP 프로젝트에 resources 폴더를 추가한다.

 

resources 폴더를 생성 후 데이터 파일을 생성한다.

 

생성한 resources 폴더를 classpath에 설정한다.

 

plugin.xml의 Runtime 탭의 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();
}
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.