从HTTP连接获取响应头
/* from N o w J a v a . c o m */ import java.net.URL; import java.net.URLConnection; public class Main { public void main(String[] argv) { try { URL url = new URL("http://hostname:80"); URLConnection conn = url.openConnection(); // List all the response headers from the server. for (int i = 0;; i++) { /** nowjava.com - 时代Java **/ String headerName = conn.getHeaderFieldKey(i); String headerValue = conn.getHeaderField(i); if (headerName == null && headerValue == null) { // No more headers break; } if (header