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) { }}}}