/** 获取工程路径[字符串],Exe所在[目录]路径*/
//获得[工程路径]IProject
public static String getWorkspacePath() {
String runPath = Platform.getInstanceLocation().getURL().getPath();
String result = null;
if (!runPath.contains(":"))
return null;
int index = runPath.indexOf("workspace");
if (index < 1) {
result = runPath.substring(1, runPath.length());
} else {
result = runPath.substring(1, index);
}
return result;
}
//获得[工程路径]IProject
public static IProject getReportProject() throws CoreException {
try{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("产品下的一个目录");
if (!project.exists()) {
project.create(null);
}
if (!project.isOpen()) {
project.open(null);
}
return project;
}catch (Exception e) {
return null;
}
}