Here you can find the source of addHeadersToRequest(HttpURLConnection request, Map
public static void addHeadersToRequest(HttpURLConnection request, Map<String, String> headers)
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; import java.util.Map; public class Main { public static void addHeadersToRequest(HttpURLConnection request, Map<String, String> headers) { if (headers != null) { for (String key : headers.keySet()) { request.addRequestProperty(key, headers.get(key)); }/*from w w w . ja va 2 s .c om*/ } } }