Java URL toURI() methodThe toURI() method returns URI equivalent to given URL. This method functions in the same way as new URI (this.toString()). SyntaxReturnsA URI instance is equivalent to this URL. ThrowURISyntaxException - if this URL is not formatted strictly according to RFC2396 and cannot be converted to a URI. Since1.5 Example 1Test it NowOutput: URL created: https://www.javatpoint.com/URL-class URI from URL: https://www.javatpoint.com/URL-class Example 2Output: URL:file:/D:/Advancejava/UrlClass/file%20name%20with%20spaces.txt URI:file:/D:/Advancejava/UrlClass/file%20name%20with%20spaces.txt URL (no special character handling):file:/D:/Advancejava/UrlClass/file name with spaces.txt Next TopicJava URL Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India