Give the example of using a class from the class library, JAVA Programming

Assignment Help:

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


Related Discussions:- Give the example of using a class from the class library

JAVA Cipher Program, Cryptography, the study of secret writing, has been ar...

Cryptography, the study of secret writing, has been around for a very long time, from simplistic techniques to sophisticated mathematical techniques. No matter what the form howeve

I need android kiosk mode, I need Android Kiosk Mode Project Description...

I need Android Kiosk Mode Project Description: I need an Android platform developer to develop an app when device start it start into kiosk mode. Only browser window open a c

Thread, create thread without extending anything

create thread without extending anything

What is setter methods explain with an example, What is Setter Methods expl...

What is Setter Methods explain with an example? Setter methods, also called as mutator methods, merely set the value of a field to a value specified through the argument to the

Stream as an object, What interface must an object implement before it can ...

What interface must an object implement before it can be written to a stream as an object?      Ans) An object must execute the Serializable or Externalizable interface before i

Explain the order of evaluation of logic operators, Explain the Order of Ev...

Explain the Order of Evaluation of Logic Operators ? When Java sees a && operator or a ||, the expression on the left side of the operator is evaluated first. For instance, con

Connect 4 game application, This assignment is a good project for working w...

This assignment is a good project for working with 2 dimensional arrays. In this program, you will implement an ascii version of the classic game "Connect 4". Connect 4 is a 2 p

Program with eclipse and enumeration , Problem Definition A new Met Of...

Problem Definition A new Met Office web application will allow users of their web site to view rainfall statistics for months and years in the UK. The application allows the m

What are the layers of rmi architecture, There are three layers:-  a . S...

There are three layers:-  a . Stub and Skeleton layer This layer lies just under the view of the developer. This layer intercepts method calls made by the client to the inte

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd