All pastes #465104 Raw Edit

For HolyDemon

public java v1 · immutable
#465104 ·published 2007-04-29 22:28 UTC
rendered paste body
/** * Write a description of class UrlTest here. *  * @author (your name)  * @version (a version number or a date) */import java.net.*;import java.io.*;public class UrlTest{    public static void main(String arg[]){    try {                URL url = new URL("http://google.com");        URLConnection conn = url.openConnection();                   for (int i=0; ; i++) {            String headerName = conn.getHeaderFieldKey(i);            String headerValue = conn.getHeaderField(i);                if (headerName == null && headerValue == null) {                               break;            }            if ("Set-Cookie".equalsIgnoreCase(headerName)) {                                String[] fields = headerValue.split(";\\s*");                    String cookieValue = fields[0];                String expires = null;                String path = null;                String domain = null;                boolean secure = false;                                    for (int j=1; j<fields.length; j++) {                    if ("secure".equalsIgnoreCase(fields[j])) {                        secure = true;                    } else if (fields[j].indexOf('=') > 0) {                        String[] f = fields[j].split("=");                        if ("expires".equalsIgnoreCase(f[0])) {                            expires = f[1];                        } else if ("domain".equalsIgnoreCase(f[0])) {                            domain = f[1];                        } else if ("path".equalsIgnoreCase(f[0])) {                            path = f[1];                        }                    }                }                                }        }    } catch (Exception e) {    } catch (Exception e) {    }}}}