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();}
댓글
댓글 쓰기