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

Write a program on clearing rectangles, Write a program on clearing Rectang...

Write a program on clearing Rectangles ? It is also potential to clear a rectangle that you've drawn. The syntax is exactly what you'd expect: public abstract void clearRect

Define all the members of identified classes using java, A Mexican restaura...

A Mexican restaurant in London is struggling with preparing the meal ordered by it;s customer in time and has started loosing it;s business. The owner is looking at the possibility

Draw out a uml class diagram, Question: (a) Draw out a UML class diagra...

Question: (a) Draw out a UML class diagram that captures the following information: An Employee is a kind of Person. An ATM is a kind of Machine. Both an Employee and an ATM

Custom website technical specification document, Custom Website Technical S...

Custom Website Technical Specification Document A Solution provider / System Architect to interpret and speak with me and build business functional needs and a set of research d

Define the n-tier architecture or j2ee 3-tier?, Normal 0 false ...

Normal 0 false false false EN-US X-NONE X-NONE

Program with fibonacci sequence of first 20 terms, Program 1. Write a J...

Program 1. Write a Java program to display the first 20 Fibonacci numbers Program with Fibonacci sequence of first 20 terms Output 2. Write an applet progr

Explain testing for equality with equals, Explain Testing for Equality with...

Explain Testing for Equality with equals? That's not what you expected. To contrast strings or any other kind of object you required to use the equals(Object o) techniques from

What is prototype, Prototype is having multiple instances or having clone.

Prototype is having multiple instances or having clone.

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