Reading resources from a Eclipse plugin

Bundle bundle = Platform.getBundle("de.vogella.example.readfile");
URL fileURL = bundle.getEntry("files/test.txt");

try {
    URL resolvedFileURL = FileLocator.toFileURL(fileURL);
URI resolvedURI = new URI(resolvedFileURL.getProtocol(), resolvedFileURL.getPath(), null);
File file = new File(resolvedURI);
   //file = new File(FileLocator.resolve(fileURL).toURI());
   boolean a = file.exists();
   MessageDialog.openInformation(
window.getShell(),
"Sample2",
file.toPath().toAbsolutePath().toString() + ", " + String.valueOf(a));
   System.out.println(file.toPath().toAbsolutePath().toString());
} catch (URISyntaxException e1) {
    e1.printStackTrace();
} catch (IOException e1) {
    e1.printStackTrace();
}

http://blog.vogella.com/2010/07/06/reading-resources-from-plugin/

댓글

이 블로그의 인기 게시물

Oracle NLS_DATE_FORMAT 변경

Stop console process using Ctrl+C.

Alternative to IValueConvert, QuickConverter