本文中演示如何通過URLConnection獲取Http響應Header信息
URL obj = new URL
URLConnection conn = obj
Map<String
Map<String
List<String> server = map
完整的示例
package com
import
import
import java
import java
public class GetHttpResponseHeader {
public static void main(String[] args) {
try {
URL obj = new URL
URLConnection conn = obj
Map<String
System
for (Map
System
}
System
List<String> server = map
if (server == null) {
System
} else {
for (String values : server) {
System
}
}
} catch (Exception e) {
e
}
}
}
輸出
顯示響應Header信息…
Key : null
Key : X
Key : Date
Key : Transfer
Key : Connection
Key : Content
Key : Server
Key : X
使用key獲得響應Header信息 …Apache/
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25662.html