give the example of using a class from the class


Give the example of Using a class from the class library ?

You use the java.net.URL class only like you'd use any other class along with these methods in which happens to be named java.net.URL. For example,
public class URLSplitter {

public static void main(String[] args) {

for (int i = 0; i < args.length; i++) {
try {
java.net.URL u = new java.net.URL(args[i]);
System.out.println("Protocol: " + u.getProtocol());
System.out.println("Host: " + u.getHost());
System.out.println("Port: " + u.getPort());
System.out.println("File: " + u.getFile());
System.out.println("Ref: " + u.getRef());
}
catch (java.net.MalformedURLException ex) {
System.err.println(args[i] + " is not a valid URL");
}
}

}

}
Here's the output:
$ java URLSplitter https://www.poly.edu
Protocol: http
Host: www.poly.edu
Port: -1
File: /
Ref: null

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: give the example of using a class from the class
Reference No:- TGS0284766

Expected delivery within 24 Hours