简体   繁体   English

Eclipse PDE 寻找文件的绝对路径(或相对路径)

[英]Eclipse PDE looking for the absolute path for the file (or relative path)

This is the code that I have for now but the output from this is: /Users/zakariasfridriksson/runtime-EclipseApplication/is.ru.cs.PapyrusActivityLogger.example (runtime-EclipseApplication this is wrong like it is missing some part of the path)这是我现在拥有的代码,但 output 是: /Users/zakariasfridriksson/runtime-EclipseApplication/is.ru.cs.PapyrusActivityLogger.example (runtime-EclipseApplication 这是错误的,就像它缺少路径的某些部分)

Code:代码:

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);
        

You can just call getLocation on the IFile :您可以在IFile上调用getLocation

IPath csvPath = csv.getLocation();

String dest = csvPath.toOSString();

Note: runtime-EclipseApplication is the test workspace that Eclipse has created for you when you run plug-ins using 'Run as Eclipse Application'.注意: runtime-EclipseApplication是 Eclipse 在您使用“Run as Eclipse Application”运行插件时为您创建的测试工作区。 So your original code is also giving the correct result.所以你的原始代码也给出了正确的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM