URL geturl = new URL(myurl);
HttpURLConnection conn = (HttpURLConnection)geturl.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");
String cookie = conn.getHeaderField("set-cookie");
System.out.println(cookie);
- String key = null;
- for (int i = 1; (key = http.getHeaderFieldKey(i)) != null; i++) {
- if (key.equalsIgnoreCase("set-cookie")) {
- String cookie = null;
- cookie = http.getHeaderField(i);
- int i1=cookie.indexOf("=");
- int i2=cookie.indexOf(";");
- if(i1!=-1&&i2!=-1){
- String _value=cookie.substring(i1+1, i2);
- String _key=cookie.substring(0, i1);
- cookieMap.put(_key, _value);
- }
- }
- }