code: private static URL fileToURL(Path file) {
          Path p;
          try {
              p = file.toRealPath();
          } catch (IOException e) {
              p = file.toAbsolutePath();
          }
          try {
              return p.normalize().toUri().toURL();
          } catch (MalformedURLException e) {
              return null;
          }
      }
docs: Returns the directory or JAR file URL corresponding to the specified local file name.
  
  @param file the Path object
  @return the resulting directory or JAR file URL, or null if unknown