code: public static URL getVirtualURL(VirtualFile file) throws MalformedURLException {
          try {
              final URI uri = getVirtualURI(file);
              final String scheme = uri.getScheme();
              return AccessController.doPrivileged(new PrivilegedExceptionAction<URL>() {
                  @Override
                  public URL run() throws MalformedURLException{
                      if (VFS_PROTOCOL.equals(scheme)) {
                          return new URL(null, uri.toString(), VFS_URL_HANDLER);
                      } else if ("file".equals(scheme)) {
                          return new URL(null, uri.toString(), FILE_URL_HANDLER);
                      } else {
                          return uri.toURL();
                      }
                  }
              });
          } catch (URISyntaxException e) {
              throw new MalformedURLException(e.getMessage());
          } catch (PrivilegedActionException e) {
              throw (MalformedURLException) e.getException();
          }
      }
docs: Get the virtual URL for a virtual file.  This URL can be used to access the virtual file; however, taking the file
  part of the URL and attempting to use it with the {@link java.io.File} class may fail if the file is not present
  on the physical filesystem, and in general should not be attempted.
  <b>Note:</b> if the given VirtualFile refers to a directory <b>at the time of this
  method invocation</b>, a trailing slash will be appended to the URL; this means that invoking
  this method may require a filesystem access, and in addition, may not produce consistent results
  over time.
  
  @param file the virtual file
  @return the URL
  @throws MalformedURLException if the file cannot be coerced into a URL for some reason
  @see VirtualFile#asDirectoryURL()
  @see VirtualFile#asFileURL()