MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.net.URL;

public class MainClass {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http://www.yahoo.com:80/en/index.html?name=joe#first");
        System.out.println("protocol:" + url.getProtocol());
        System.out.println("prot:" + url.getPort());
        System.out.println("host:" + url.getHost());
        System.out.println("path:" + url.getPath());
        System.out.println("file:" + url.getFile());
        System.out.println("query:" + url.getQuery());
        System.out.println("ref:" + url.getRef());
    }
}