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

How can we include images in a web page using html and java, How can we inc...

How can we include images in a web page using HTML and Java script? Image in HTML Image in Javascript Images in JavaScript could be manipulated in several ways using the buil

Socket in java networking and rmi, What Is a Socket in Java Networking and ...

What Is a Socket in Java Networking and RMI? Ans) A socket is one end-point of a two-way communication link among two programs running on the network. A socket is bound to a por

What are the basic components of jsp?, There are two different types of dat...

There are two different types of data in a JSP page. 1. Static part which occurs copied directly to the response by the JSP Engine. 2. Dynamic part, which have anything that

Why do we call javascript an object-based language, Why do we call JavaScri...

Why do we call JavaScript an Object-based Language? In java language an JavaScript shares several similarities with object-oriented languages, and thus is known as an object-ba

Define the j2ee best practices to improve performance? , Manage valuable re...

Manage valuable resources recycle and wisely them where possible, serialization cost and minimize network overheads, and optimize all your database functions. 1. Recycle and man

Write a program of else statement in java, Write a program of else statemen...

Write a program of else statement in java? The else statement in Java // This is the Hello program in Java class Hello { public static void main (String args[]) { if (

What are the difference between throw and throws, What are the difference b...

What are the difference between throw and throws? Differences are between throws and throw are: Throw is employed to trigger an exception while throws is used in declara

Padovan String, A Padovan string P(n) for a natural number n is defined as:...

A Padovan string P(n) for a natural number n is defined as: P(0)=''X'' P(1)=''Y'' P(2)=''Z'' for a string characters ''X'',''Y'',''Z'' only,and given value of n,write a program th

Student, need help in assignment

need help in assignment

Explain about the dynamic behavior of core java, This language was designed...

This language was designed to adapt the changing environment and behavior. New methods and instance variables can be added to the client side without any major changes happening at

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