Here you can find the source of getHeaderField(final URL url, final String name)
public static String getHeaderField(final URL url, final String name)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.URLConnection; import java.net.URL; import java.net.HttpURLConnection; public class Main { public static String getHeaderField(final URL url, final String name) { URLConnection conn = null; try {//from ww w .j av a 2 s. com // Create a URLConnection object for a URL conn = openConnection(url); return conn.getHeaderField(name); } catch (IOException e) { e.printStackTrace(); return null; } finally { if (conn != null && conn instanceof HttpURLConnection) { ((HttpURLConnection) conn).disconnect(); } } } private static URLConnection openConnection(final URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setReadTimeout(3000); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return conn; } }