<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: java.net.URL or java.net.URI?</title>
	<atom:link href="http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/</link>
	<description>Living in a state of accord.</description>
	<pubDate>Sun, 23 Nov 2008 13:17:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Anonymous</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68620</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 30 Mar 2007 22:20:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68620</guid>
		<description>Never. However, the only reason I've compared URLs before is for really primitive caching, and the URLs would have been constructed from the exact same String. Getting an unexpected false wouldn't matter either. So while I've done an awful lot with HTTP, my usage of URLs has really just been a storage container - it could have been a String for all I really cared (and in many cases, it was a String).</description>
		<content:encoded><![CDATA[<p>Never. However, the only reason I&#8217;ve compared URLs before is for really primitive caching, and the URLs would have been constructed from the exact same String. Getting an unexpected false wouldn&#8217;t matter either. So while I&#8217;ve done an awful lot with HTTP, my usage of URLs has really just been a storage container - it could have been a String for all I really cared (and in many cases, it was a String).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asbjørn Ulsberg</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68602</link>
		<dc:creator>Asbjørn Ulsberg</dc:creator>
		<pubDate>Fri, 30 Mar 2007 13:49:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68602</guid>
		<description>Sounds like a smart pick and plan to me. When you say you've worked successfully with the URL class for at least 5 years, have you in any of those 5 years done url1.equals(url2) and not had unexpected results?</description>
		<content:encoded><![CDATA[<p>Sounds like a smart pick and plan to me. When you say you&#8217;ve worked successfully with the URL class for at least 5 years, have you in any of those 5 years done url1.equals(url2) and not had unexpected results?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Sutton</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68596</link>
		<dc:creator>Adrian Sutton</dc:creator>
		<pubDate>Fri, 30 Mar 2007 08:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68596</guid>
		<description>Well, I've been successfully working with the URL class for at least the past 5 years - as much as anything out of necessity because that's what everything tends to use. All I really need in this case is an identifier - some other code will have to deal with retrieving resources, I just need a unique name to assign them so that they can be stored and retrieved in the cache, given the design of HTTP the obvious answer is a URL/URI. It is likely to be more useful for clients of the API to use URLs but it is easier to convert URLs to URIs than visa versa and given the advice that the URL class is so broken I've gone with java.net.URI. No doubt I'll need to add utility methods that take URLs and convert them to URIs at some point, but this will let me keep moving forward and see if this becomes a worthwhile project or not.</description>
		<content:encoded><![CDATA[<p>Well, I&#8217;ve been successfully working with the URL class for at least the past 5 years - as much as anything out of necessity because that&#8217;s what everything tends to use. All I really need in this case is an identifier - some other code will have to deal with retrieving resources, I just need a unique name to assign them so that they can be stored and retrieved in the cache, given the design of HTTP the obvious answer is a URL/URI. It is likely to be more useful for clients of the API to use URLs but it is easier to convert URLs to URIs than visa versa and given the advice that the URL class is so broken I&#8217;ve gone with java.net.URI. No doubt I&#8217;ll need to add utility methods that take URLs and convert them to URIs at some point, but this will let me keep moving forward and see if this becomes a worthwhile project or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asbjørn Ulsberg</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68595</link>
		<dc:creator>Asbjørn Ulsberg</dc:creator>
		<pubDate>Fri, 30 Mar 2007 08:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68595</guid>
		<description>What are you going to do with the URIs/URLs in your application? If you're going to resolve them and have to rely on the URL class itself to do that, then that might make sense in a very obscure way. However, I think that's just as wrong as having readFile() and writeFile() methods on the String class. It just doesn't belong there, and if it was there, the class would be badly designed and imho broken. Thus, the URL class is broken.

If what you want is a generic class to represent the URI syntax with convenient methods to handle this syntax (e.g. extract portions of the URI for further inspection etc.), and leave resolving to a class better equipped to do it, then URI is definately the way to go. As Tim Bray writes, don't go near the URL class, at least not unless you have explicit, well-thought and very sound reasons to do it.</description>
		<content:encoded><![CDATA[<p>What are you going to do with the URIs/URLs in your application? If you&#8217;re going to resolve them and have to rely on the URL class itself to do that, then that might make sense in a very obscure way. However, I think that&#8217;s just as wrong as having readFile() and writeFile() methods on the String class. It just doesn&#8217;t belong there, and if it was there, the class would be badly designed and imho broken. Thus, the URL class is broken.</p>
<p>If what you want is a generic class to represent the URI syntax with convenient methods to handle this syntax (e.g. extract portions of the URI for further inspection etc.), and leave resolving to a class better equipped to do it, then URI is definately the way to go. As Tim Bray writes, don&#8217;t go near the URL class, at least not unless you have explicit, well-thought and very sound reasons to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Sutton</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68579</link>
		<dc:creator>Adrian Sutton</dc:creator>
		<pubDate>Thu, 29 Mar 2007 22:18:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68579</guid>
		<description>Ok, so out of all of that I think my understanding was fairly right, if uncertain. URLs are a specific type of URI, every URL should be a valid URI and Java just screws it all up. Fair enough.

From a practical standpoint though I'm still in two minds - java.net.URL may be horribly broken, but it is what everyone uses. It seems unlikely that a HTTP caching algorithm would be useful for things that aren't identified by URLs (exactly how do I send a HTTP request for urn:isbn:xxxx-xxxx-xxxx?) so I probably should just use them. I can always add a URI interface as well later if it ever proves useful.</description>
		<content:encoded><![CDATA[<p>Ok, so out of all of that I think my understanding was fairly right, if uncertain. URLs are a specific type of URI, every URL should be a valid URI and Java just screws it all up. Fair enough.</p>
<p>From a practical standpoint though I&#8217;m still in two minds - java.net.URL may be horribly broken, but it is what everyone uses. It seems unlikely that a HTTP caching algorithm would be useful for things that aren&#8217;t identified by URLs (exactly how do I send a HTTP request for urn:isbn:xxxx-xxxx-xxxx?) so I probably should just use them. I can always add a URI interface as well later if it ever proves useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Venz</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68573</link>
		<dc:creator>David Venz</dc:creator>
		<pubDate>Thu, 29 Mar 2007 20:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68573</guid>
		<description>The above comments are probably of more immediate use, but as another data-point:
Have you read RFC 3305, in particular section 2?

Cheers,
-Dave.</description>
		<content:encoded><![CDATA[<p>The above comments are probably of more immediate use, but as another data-point:<br />
Have you read RFC 3305, in particular section 2?</p>
<p>Cheers,<br />
-Dave.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Snell</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68544</link>
		<dc:creator>James Snell</dc:creator>
		<pubDate>Thu, 29 Mar 2007 14:46:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68544</guid>
		<description>As Tim and Steve point out, java.net.URL is evil.  java.net.URI is not a whole lot better but it's still the best choice.</description>
		<content:encoded><![CDATA[<p>As Tim and Steve point out, java.net.URL is evil.  java.net.URI is not a whole lot better but it&#8217;s still the best choice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Loughran</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68539</link>
		<dc:creator>Steve Loughran</dc:creator>
		<pubDate>Thu, 29 Mar 2007 12:59:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68539</guid>
		<description>Do not go near java.net.URL if you can help it. In some recently fixed releases of Java, it would hang the thread in the Constructor until a reverse DNS lookup of the proxy server timed out.</description>
		<content:encoded><![CDATA[<p>Do not go near java.net.URL if you can help it. In some recently fixed releases of Java, it would hang the thread in the Constructor until a reverse DNS lookup of the proxy server timed out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Bray</title>
		<link>http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68538</link>
		<dc:creator>Tim Bray</dc:creator>
		<pubDate>Thu, 29 Mar 2007 12:32:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/#comment-68538</guid>
		<description>I'd say URI is the only sane choice.  See http://www.tbray.org/ongoing/When/200x/2003/02/27/URL and http://www.w3.org/TR/webarch and for a nasty surprise, check out the sickening broken-ness of java.net.URL.equals()</description>
		<content:encoded><![CDATA[<p>I&#8217;d say URI is the only sane choice.  See <a href="http://www.tbray.org/ongoing/When/200x/2003/02/27/URL" rel="nofollow">http://www.tbray.org/ongoing/When/200x/2003/02/27/URL</a> and <a href="http://www.w3.org/TR/webarch" rel="nofollow">http://www.w3.org/TR/webarch</a> and for a nasty surprise, check out the sickening broken-ness of java.net.URL.equals()</p>
]]></content:encoded>
	</item>
</channel>
</rss>
