file = file.substring(0, file.lastIndexOf('/')) + '/' + spec.substring(start, end);
char sepChar = '/'; int lastSlash = file.lastIndexOf (sepChar); if (lastSlash < 0 && File.separatorChar != sepChar && url.getProtocol ().equals ("file")) {  sepChar = File.separatorChar; lastSlash = file.lastIndexOf (sepChar); }  file = file.substring(0, lastSlash) + sepChar + spec.substring (start, end);  if (url.getProtocol ().equals ("file")) {   try { file = new File (file).getCanonicalPath (); } catch (IOException e) { } }
  protected void parseURL(URL url, String spec, int start, int end)  {    String host = url.getHost();    int port = url.getPort();    String file = url.getFile();    String ref = url.getRef();        if (spec.regionMatches (start, "//", 0, 2))      {	int hostEnd;	int colon;	start += 2;	int slash = spec.indexOf('/', start);	if (slash >= 0) 	  hostEnd = slash;        else	  hostEnd = end;	host = spec.substring (start, hostEnd);		// Look for optional port number.  It is valid for the non-port	// part of the host name to be null (e.g. a URL "http://:80").	// TBD: JDK 1.2 in this case sets host to null rather than "";	// this is undocumented and likely an unintended side effect in 1.2	// so we'll be simple here and stick with "". Note that	// "http://" or "http:///" produce a "" host in JDK 1.2.	if ((colon = host.indexOf(':')) >= 0)	  {	    try	      {		port = Integer.parseInt(host.substring(colon + 1));	      }	    catch (NumberFormatException e)	      {		; // Ignore invalid port values; port is already set to u's		  // port.	      }	    host = host.substring(0, colon);	  }	file = null;	start = hostEnd;      }     else if (host == null)       host = "";    if (file == null || file.length() == 0	|| (start < end && spec.charAt(start) == '/'))       {	// No file context available; just spec for file.	// Or this is an absolute path name; ignore any file context.	file = spec.substring(start, end);	ref = null;      }     else if (start < end)      {	// Context is available, but only override it if there is a new file.	file = file.substring(0, file.lastIndexOf('/'))		+ '/' + spec.substring(start, end);	ref = null;      }    if (ref == null)      {	// Normally there should be no '#' in the file part,	// but we are nice.	int hash = file.indexOf('#');	if (hash != -1)	  {	    ref = file.substring(hash + 1, file.length());	    file = file.substring(0, hash);	  }      }    // XXX - Classpath used to call PlatformHelper.toCanonicalForm() on    // the file part. It seems like overhead, but supposedly there is some    // benefit in windows based systems (it also lowercased the string).    setURL(url, url.getProtocol(), host, port, file, ref);  }