How to get VirtualFile from a VirtualFile URL in IntelliJ

时间:2016-02-03 04:08:00

标签: intellij-idea intellij-plugin

I am working on plugin in on IntelliJ.

Now I have a VirtualFile file, I am trying to write file.getUrl() to local file system so that I can get file back when I restart my plugin. But It seems I can not get the VirtualFile from a url?

2 个答案:

答案 0 :(得分:0)

要按网址查找文件,请使用VirtualFileManager.findFileByUrl()source)。或者保持简单,存储路径并按照@vikingsteve的建议使用LocalFileSystem.findFileByPath()

答案 1 :(得分:0)

 VirtualFile[] vFiles = ProjectRootManager.getInstance(this.project).getContentRoots();
 VirtualFile stateMachineConfig = vFiles[0].findChild("stateConfig.json");