How to get HTTP Response Header in Java

This example shows you how to get the Http response header values in Java. 1. Standard JDK example. URL obj = new URL("https://mkyong.com"); URLConnection conn = obj.openConnection(); //get all headers Map<String, List<String>> map = conn.getHeaderFields(); for (Map.Entry<String, List<String>> entry : map.entrySet()) { System.out.println("Key : " + entry.getKey() + " ,Value : " + entry.getValue()); } …

Read more