[英]How to get the absolute path of eclipse project to use in .bat file?
[英]Absolute Path of project file in eclipse
我想在eclipse插件中打印文件rep.xml
的絕對路徑。
我已將文件rep.xml
放在路徑下
C:\\Program Files\\Eclipse\\Documents\\Eclipse\\samplePlugin\\resources\\rep.xml.
我嘗試使用file.getLocation()
打印它。
它返回C:/Program Files/eclipse/Documents/runtime-EclipseApplication
如何在Eclipse中打印絕對路徑。 請幫忙。
如果您想讀取插件中包含的文件,請使用以下命令:
Bundle bundle = Platform.getBundle("your plugin id");
URL url = FileLocator.find(bundle, new Path("path relative to the plugin"), null);
URL fileUrl = FileLocator.toFileURL(url);
File file = new File(fileUrl.getFile());
... read file using normal Java file APIs
您還可以使用FrameworkUtil
來獲取捆綁包,從而避免對插件ID進行硬編碼:
Bundle bundle = FrameworkUtil.getBundle(getClass());
給您包含給定類的Bundle
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.