code: protected URL getURL(File file, boolean encoded)
          throws MalformedURLException {
  
          File realFile = file;
          try {
              realFile = realFile.getCanonicalFile();
          } catch (IOException e) {
              // Ignore
          }
          if(encoded) {
              return getURI(realFile);
          } else {
              return realFile.toURL();
          }
  
      }
docs: Get URL.