Java Programming Practical 24

Question 1
Write a program using URL class to retrieve the host, protocol, port and file of URL http://www.msbte.org.in
URLDemo.java
Java
				import java.net.*;
class URLDemo
{
    public static void main(String args[])throws MalformedURLException
    {
        URL netAddress=new URL("http://www.msbte.org.in");
        System.out.println("Protocol:"+netAddress.getProtocol());
        System.out.println("Port:"+netAddress.getPort());
        System.out.println("Host:"+netAddress.getHost());
        System.out.println("File:"+netAddress.getFile());
    }
}

			
Output

Leave a Comment

Your email address will not be published. Required fields are marked *