[Patch] java.net.URL
Michael Koch
konqueror@gmx.de
Wed Apr 20 05:35:00 GMT 2005
Hi list,
I just commited the attached patch to implement the toURI() method in
java.net.URL. This is a merged patch from GNU classpath.
Michael
2005-04-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/net/URL.java:
(toURI()): Implemented.
-------------- next part --------------
Index: java/net/URL.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.48
diff -u -r1.48 URL.java
--- java/net/URL.java 19 Apr 2005 10:31:51 -0000 1.48
+++ java/net/URL.java 20 Apr 2005 05:34:03 -0000
@@ -953,4 +953,21 @@
{
oos.defaultWriteObject();
}
+
+ /**
+ * Returns the equivalent <code>URI</code> object for this <code>URL</code>.
+ * This is the same as calling <code>new URI(this.toString())</code>.
+ * RFC2396-compliant URLs are guaranteed a successful conversion to
+ * a <code>URI</code> instance. However, there are some values which
+ * form valid URLs, but which do not also form RFC2396-compliant URIs.
+ *
+ * @throws URISyntaxException if this URL is not RFC2396-compliant,
+ * and thus can not be successfully converted to a URI.
+ */
+ public URI toURI()
+ throws URISyntaxException
+ {
+ return new URI(toString());
+ }
+
}
More information about the Java-patches
mailing list