0% found this document useful (0 votes)
16 views4 pages

Exp 15

Uploaded by

Samarth Mhetre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Exp 15

Uploaded by

Samarth Mhetre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Exp15_st1_10

import java.net.MalformedURLException;

import java.net.URL;

public class Exp15_st1_10 {

public static void main(String[] args)throws MalformedURLException

URL hp= new URL("https://www.msbte.org.in");

System.out.println("Protocol:"+hp.getProtocol());

System.out.println("port:"+hp.getPort());

System.out.println("Host:"+hp.getHost());

System.out.println("File:"+hp.getFile());

}
Output:
Exp15_st2_10
import java.io.*;

import java.net.*;

import java.util.*;

public class Exp15_st2_10 {

public static void main(String[] args) {

try {

System.out.println("Enter the URL");

BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

String conn = bf.readLine();

URL url = new URL(conn);

URLConnection uc = url.openConnection();

System.out.println("Date :-" + new Date(uc.getLastModified()));

System.out.println("Content Type" + uc.getContentType());

System.out.println("Content Length :-" + uc.getContentLength());

} catch (Exception e) {

System.out.println(e);

}
Output:

You might also like