Here you can find the source of addCustomHeaders(HttpURLConnection conn, Map
private static void addCustomHeaders(HttpURLConnection conn, Map<String, String> headers)
//package com.java2s; //License from project: Open Source License import java.net.*; import java.util.*; public class Main { private static void addCustomHeaders(HttpURLConnection conn, Map<String, String> headers) { for (Map.Entry<String, String> entry : headers.entrySet()) { addHeader(conn, entry.getKey(), entry.getValue()); }/* w w w. j a v a2s . c o m*/ } private static void addHeader(HttpURLConnection conn, String headerName, String value) { conn.setRequestProperty(headerName, value); } }