+ 1
+ 3
Archisman Chatterjee
You have lots of mistake:
1 - where is try block, catch can't be without try block
2 - check proper opening and closing curly braces {}
3 - there is util package not utill
4 - there is List class not list class, class name should start from capital letter.
5 - where did you declare variable i
+ 3
- remove catch block
catch (Exception e) {
System.out.println(e);
}
-instead catch, add throws after main() line , (it is simpler)
public static void main(String args[])
throws Exception {
-rename utill to util
-rename list to List
-declare i before while()
String i; //
+ 2
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class URLConnectionclass
{
public static void main (String args[])
{
try
{
URL url = new URL("https://innovateindia.mygov.in/ppc-2022/");
URLConnection urlcon= url.openConnection();
Map<String, List<String>> header = urlcon.getHeaderFields();
for (Map.Entry<String, List<String>> mp: header.entrySet()){
System.out.println("\nComplete source code of the URL is---");
System.out.println("------------------------------------------");
BufferedReader br= new BufferedReader(new InputStreamReader(urlcon.getInputStream ()));
String i;
// print the source code line by line
while(( i = br.readLine()) != null)
{
System.out.println(i);
}
}
}
catch (Exception e)
{
System.out.println(e);
}
}
} //it's working...