[英]Eclipse PDE looking for the absolute path for the file (or relative path)
這是我現在擁有的代碼,但 output 是: /Users/zakariasfridriksson/runtime-EclipseApplication/is.ru.cs.PapyrusActivityLogger.example (runtime-EclipseApplication 這是錯誤的,就像它缺少路徑的某些部分)
代碼:
IProject project = root.getProject("is.ru.cs.PapyrusActivityLogger.example");
System.out.println(project.getFullPath());
IFile csv = project.getFile("logger.csv");
String finaldestination = root.getLocation().toString() + project.getFullPath();
System.out.println(finaldestination);
您可以在IFile
上調用getLocation
:
IPath csvPath = csv.getLocation();
String dest = csvPath.toOSString();
注意: runtime-EclipseApplication
是 Eclipse 在您使用“Run as Eclipse Application”運行插件時為您創建的測試工作區。 所以你的原始代碼也給出了正確的結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.