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(

1 comment

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!


Please sign in to leave a comment.