Default URL Object In Java Example
Chapter:
Networking
Last Updated:
18-07-2016 04:48:21 UTC
Program:
/* ............... START ............... */
import java.net.MalformedURLException;
import java.net.URL;
public class JavaDefaultURL {
public static void main(String a[]) {
try {
String myUrl = "http://www.javascan.com";
URL url = new URL(myUrl);
System.out.println(url.toString());
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
}
/* ............... END ............... */
Output
Notes:
-
The easiest way to create a URL object is from a String that represents the human-readable form of the URL address.
- Syntax : URL myURL = new URL("https://www.javascan.com/");
Tags
Default URL Object, Java