Here you can find the source of setHeaders(HttpURLConnection conn, List
private static void setHeaders(HttpURLConnection conn, List<String> headers, String encoding)
//package com.java2s; //License from project: Apache License import java.net.HttpURLConnection; import java.util.Iterator; import java.util.List; public class Main { private static void setHeaders(HttpURLConnection conn, List<String> headers, String encoding) { if (null != headers) { for (Iterator<String> iter = headers.iterator(); iter.hasNext();) { conn.addRequestProperty(iter.next(), iter.next()); }// w w w . ja va 2 s.co m } conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + encoding); } }