0% found this document useful (0 votes)
3 views

java prac 15 (1)

The Java program connects to a specified URL and retrieves various properties of the URL connection, such as user interaction allowance, content type, and last modified date. It also prints the headers of the URL connection and the complete source code of the webpage. Any exceptions that occur during the execution are caught and printed to the console.

Uploaded by

sanketgithub10
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

java prac 15 (1)

The Java program connects to a specified URL and retrieves various properties of the URL connection, such as user interaction allowance, content type, and last modified date. It also prints the headers of the URL connection and the complete source code of the webpage. Any exceptions that occur during the execution are caught and printed to the console.

Uploaded by

sanketgithub10
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Program :

import java.net.*;
import java.util.*;
import java.io.*;
public class xyz
{
public static void main(String args[])
{
try
{
URL url = new URL("https://mabte.org.in");
URLConnection urleon = url.openConnection();
System.out.println(urleon.getAllowUserInteraction());
System.out.println(urleon.getContentType());
System.out.println(urleon.getURL());
System.out.println(urleon.getDoInput());
System.out.println(urleon.getDoOutput());
System.out.println(new Date(urleon.getLastModified()));
System.out.println(urleon.getContentEncoding());
Map < String,List < String >> header = urleon.getHeaderFields();
for (Map.Entry < String,List <String >> mp : header.entrySet())
{
System.out.print(mp.getKey()+":");
System.out.println(mp.getValue().toString());
}
System.out.println();
System.out.println("Complete source code of the URL is");
System.out.println("..................................");
BufferedReader br = new BufferedReader(new
InputStreamReader(urleon.getInputStream()));
String i;
while ((i = br.readLine()) != null)
{
System.out.println(i);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Output :

You might also like