From b515669fbbf60e9e911ea232570bacc1a07ecdae Mon Sep 17 00:00:00 2001 From: mkoch Date: Wed, 20 Apr 2005 05:34:29 +0000 Subject: 2005-04-20 Andrew John Hughes * java/net/URL.java: (toURI()): Implemented. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98437 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/net/URL.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libjava/java/net/URL.java') diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index ec86766ba37..7eb68cb3f07 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -953,4 +953,21 @@ public final class URL implements Serializable { oos.defaultWriteObject(); } + + /** + * Returns the equivalent URI object for this URL. + * This is the same as calling new URI(this.toString()). + * RFC2396-compliant URLs are guaranteed a successful conversion to + * a URI 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()); + } + } -- cgit v1.2.3