host = u.getHost(); if (host == null) host = "";  port = u.getPort(); file = u.getFile(); ref = u.getRef();
file = url.getFile(); ref = url.getRef();
	protected String toExternalForm(URL u) {		String protocol, host, file, ref;		int port;		protocol = u.getProtocol();		// JDK 1.2 online doc infers that host could be null because it		// explicitly states that file cannot be null, but is silent on host.		host = u.getHost();		if (host == null)			host = "";		port = u.getPort();		file = u.getFile();		ref = u.getRef();		// Guess a reasonable size for the string buffer so we have to resize		// at most once.		int size = protocol.length() + host.length() + file.length() + 24;		StringBuffer sb = new StringBuffer(size);		if (protocol != null && protocol.length() > 0) {			sb.append(protocol);			sb.append(":");		}		if (host.length() != 0)			sb.append("//").append(host);		// Note that this produces different results from JDK 1.2 as JDK 1.2		// ignores a non-default port if host is null or "".  That is inconsistent		// with the spec since the result of this method is spec'ed so it can be		// used to construct a new URL that is equivalent to the original.		boolean port_needed = port > 0 && port != getDefaultPort();		if (port_needed)			sb.append(':').append(port);		sb.append(file);		if (ref != null)			sb.append('#').append(ref);		return sb.toString();	}