private static URL fileToURL(File file){
  String name;
  try {
    name=file.getCanonicalPath();
  }
 catch (  IOException e) {
    name=file.getAbsolutePath();
  }
  name=name.replace(File.separatorChar,'/');
  if (!name.startsWith("/")) {
    name="/" + name;
  }
  if (!file.isFile()) {
    name=name + "/";
  }
  try {
    return new URL("file","",name);
  }
 catch (  MalformedURLException e) {
    throw new IllegalArgumentException("file");
  }
}

private static URL fileToURL ( File file ) { String name ; try { name = file . getCanonicalPath ( ) ; } catch ( IOException e ) { name = file . getAbsolutePath ( ) ; } name = name . replace ( File . separatorChar , '/' ) ; if ( ! name . startsWith ( "/" ) ) { name = "/" + name ; } if ( ! file . isFile ( ) ) { name = name + "/" ; } try { return new URL ( "file" , "" , name ) ; } catch ( MalformedURLException e ) { throw new IllegalArgumentException ( "file" ) ; } }
returns the directory or jar file url corresponding to the specified local file name .
