tags:

views:

276

answers:

4

A quick Google didn't turn up a definitive answer. If URI does do this, is there a widespread third-party library that won't do this? I just need some parsing, and I can't have unpredictable delays while the constructor attempts to resolve a URI?

Thanks.

+2  A: 

Read this thread - http://www.symphonious.net/2007/03/29/javaneturl-or-javaneturi/

adatapost
That's the link I was thinking of when I said it didn't turn up a *definitive* answer. Asbjørn Ulsberg's comment strongly implies that it doesn't, but I was hoping for a simple yes/no, preferably with a pointer to some Sun docs that explicitly state it one way or another.
Hank Gay
+2  A: 

A quick perusal of the code of URL didn't show that it does the lookup on construction, rather on hashcode. But URI does not do appear to do this at all (that I could see).

Yishai
+1  A: 

No, it does not try to resolve anything, blocking like the equals() of URL does.

You can look in your JDK installation directory for the file src.zip. Lookup the source code for class java.net.URI in there, and you can see exactly what it does.

Jesper
+4  A: 

From the URI javadoc:

No lookup of the host, if any, is performed, and no scheme-dependent stream handler is constructed. Equality, hashing, and comparison are defined strictly in terms of the character content of the instance. In other words, a URI instance is little more than a structured string that supports the syntactic, scheme-independent operations of comparison, normalization, resolution, and relativization.

McDowell