Unable to find VirtualFile by url on Windows OS

已回答
val fileUrlString = virtualFile.url
val url = URL(fileUrlString)
val scopeFile = VfsUtil.findFileByURL(url)

That approach is working good for linux, but for windows file is not found.

Could you please tell me how to implement fileSystem independent file search?

If we will try to 'getNioPath' and then search by com.intellij.openapi.vfs.VfsUtil#findFile(java.nio.file.Path, boolean) it works only for local file system and not for remote(

0

Found out that to properly convert virtualFileUrl to java.net.URL we need to use com.intellij.openapi.vfs.VfsUtilCore#convertToURL.

Now everything works fine!

0

请先登录再写评论。