Java tutorial
//package com.java2s; import java.net.HttpURLConnection; import java.util.Map; public class Main { private static void addProperty(HttpURLConnection connection, Map<String, String> headers) { if (headers == null || headers.size() == 0) { return; } for (Map.Entry<String, String> entry : headers.entrySet()) { connection.addRequestProperty(entry.getKey(), entry.getValue()); } } }