Hey all

Just thought id share a bit of code with you in case anyone else was trying to achieve the same thing I was.

Basically I wanted to make an application that would send out HTTP requests of different methods, and read the response with the headers and the HTML. This is just the part that loops through and displays the headers key value pairs. Id never really come across Maps before, and I was confused over how to simply iterate through, but it seemed simple when i got it!

('connection' is a reference to a HttpURLConnection object)

Code:
Map<String,List <String>> headerMap = new LinkedHashMap<String,List <String>>();
headerMap = connection.getHeaderFields();
		    
System.out.println("Headers:");
for (String key : headerMap.keySet()) {
     System.out.print(key + " : " );
     for (String value : headerMap.get(key)) {
	 System.out.println(value);
     }
}
T