0% found this document useful (0 votes)
7 views1 page

Practical 15

The Java program establishes a connection to the URL 'https://mabte.org.in' and retrieves various properties of the connection, such as user interaction allowance, content type, URL, input/output capabilities, last modified date, and content encoding. It also prints the HTTP header fields and their values. The program handles exceptions and indicates when all tasks are completed.

Uploaded by

sanketgithub10
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)
7 views1 page

Practical 15

The Java program establishes a connection to the URL 'https://mabte.org.in' and retrieves various properties of the connection, such as user interaction allowance, content type, URL, input/output capabilities, last modified date, and content encoding. It also prints the HTTP header fields and their values. The program handles exceptions and indicates when all tasks are completed.

Uploaded by

sanketgithub10
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/ 1

Program:

import java.net.*;
import java.util.*;
import java.io.*;
public class Abc
{
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();
}
}

catch(Exception e)
{
System.out.println(e);
}
System.out.print(".....All task completed");
}
}
Output:

You might also like