Java tutorial
import java.net.URL; import java.net.URLConnection; import java.util.Iterator; import java.util.List; import java.util.Map; public class Main { public static void main(String[] args) throws Exception { URL url = new URL("http://www.google.com/index.html"); URLConnection connection = url.openConnection(); Map responseMap = connection.getHeaderFields(); for (Iterator iterator = responseMap.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); System.out.println(key + " = "); List values = (List) responseMap.get(key); for (int i = 0; i < values.size(); i++) { Object o = values.get(i); System.out.println(o + ", "); } } } }