Aamras in Summer
Aamras in Summer
import java.io.*;
import java.net.*;
import java.net.URL;
import java.net.MalformedURLException;
public class URLRetrive
{
public static void main(String[] args) throws MalformedURLException {
URL url = new URL("https://msbte.org.in/");
System.out.println("Authority: "+ url.getAuthority());
System.out.println("Default Port: "+ url.getDefaultPort());
System.out.println("File: "+ url.getFile());
System.out.println("Path: "+ url.getPath());
System.out.println("Protocol: "+ url.getProtocol());
System.out.println("Reference: "+ url.getRef());
}}
Output :
3. ) Write a program using URL and URLConnection class to retrieve the
date, content type, content length information of any entered URL
import java.net.URL;
import java.net.URLConnection;
import java.io.IOException;
import java.util.Date;
} catch (IOException e) {
System.out.println("An error occurred: " + e.getMessage());
}
}
}
Output :