Java API Tutorial - Java URI.toURL()








Syntax

URI.toURL() has the following syntax.

public URL toURL()  throws MalformedURLException

Example

In the following code shows how to use URI.toURL() method.

import java.net.URI;
import java.net.URL;
/*w ww  . j  av a 2s  .c  om*/
public class Main {
  public static void main(String[] args) throws Exception {

    URI uri = new URI("http://java2s.com/");
    URL url = uri.toURL();
    System.out.println(url);
  }
}

The code above generates the following result.