javadictionaryheaderjax-rskeyset

Jax-RS : extracting specific header from head call response?


I have the following code:

MultivaluedMap<String, Object> headers = requestBuilder.build("persons", queryParams).head().getHeaders();

//print all headers for trace
for(Object header : headers.keySet()){
  System.out.println(header);
 }

What is the most efficient way to extract one header: i.e. "count" from the above map of header responses?


Solution

  • Get it from the map by the key name:

    headers.get("count")