Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 如何获取Intellij工作区位置URI_File_Path_Intellij Idea_Workspace - Fatal编程技术网

File 如何获取Intellij工作区位置URI

File 如何获取Intellij工作区位置URI,file,path,intellij-idea,workspace,File,Path,Intellij Idea,Workspace,什么方法返回工作区的URI位置。对于Ex,如果工作区是C:\Intellij\workspace。我需要路径C:\Intellij\Workspace 在eclipse中,我可以这样做: File getWorkspaceRoot() { return ResourcesPlugin.getWorkspace().getRoot().getRawLocation().makeAbsolute().toFile(); } 如何在Intellij中做到这一点?Intellij没有Eclip

什么方法返回工作区的URI位置。对于Ex,如果工作区是C:\Intellij\workspace。我需要路径C:\Intellij\Workspace

在eclipse中,我可以这样做:

File getWorkspaceRoot() {
    return ResourcesPlugin.getWorkspace().getRoot().getRawLocation().makeAbsolute().toFile();
}

如何在Intellij中做到这一点?

Intellij没有Eclipse这样的工作区概念。 你和项目一起工作。启动一个新项目,项目名称在左侧的“项目”面板中给出。在括号中可以找到项目在磁盘上的位置。 一旦您想要启动或打开一个新项目,系统会要求您将当前项目替换为新项目或在新窗口中启动它

更多信息可在此处找到:


@MathiasGhys是正确的。如果这些信息不能完全解决您的问题,您可以解释一下为什么需要项目的根目录,以及在哪里需要项目的根目录。很可能有一种方法可以在没有IDE锁的情况下做你想做的事情,就像你上面展示的那样。我找到了我需要的类,com.intellij.openapi.project.project.Ah,我没有意识到这是用于插件开发的。很高兴你找到了你需要的。