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);

小怪兽爱吃肉
胡说叔叔
随时随地看视频慕课网APP
相关分类