java - Browser get current url or response header -
how can response header or current url of browser( redirects page) swt browser object or other browser in java?
import java.io.ioexception; import java.net.malformedurlexception; import java.net.url; import java.net.urlconnection; import java.util.iterator; import java.util.list; import java.util.map; public class httpresponseheaderdemo { public static void main(string[] args) { try { url url = new url("http://www.domain.com/index.html"); urlconnection connection = url.openconnection(); map responsemap = connection.getheaderfields(); (iterator iterator = responsemap.keyset().iterator(); iterator.hasnext();) { string key = (string) iterator.next(); system.out.print(key + " = "); list values = (list) responsemap.get(key); (int = 0; < values.size(); i++) { object o = values.get(i); system.out.print(o + ", "); } system.out.println(""); } } catch (malformedurlexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } }
Comments
Post a Comment