题目描述
题目来源及自己的思路
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
URL url = new URL("HTTP://km.oa.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setInstanceFollowRedirects(false);
CookieManager manager = new CookieManager();
manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
con.getInputStream();
System.out.println(con.getResponseCode());
CookieStore store = manager.getCookieStore();
List<HttpCookie> cookie = store.getCookies();
System.out.println(cookie);
for (HttpCookie coo : cookie) {
System.out.println(coo);
}
String str = con.getHeaderField("set-cookie");
System.out.println(str);
需要在