Java get response code from URL -


while (it.isvalid()) {         simpleattributeset s = (simpleattributeset) it.getattributes();         linkurls = (string) s.getattribute(html.attribute.href);          if (linkurls != null) {              system.out.println(linkurls);          }         it.next();      } 

this loop shows urls.

how display getresponsecode () each address? must done in loop? can write such code? not know how go it.

you're going need open urls, warned relative or protocol-relative (unless library you). once rebuild url, do

url url = new url(urlstr);  // might idea validate connection type before casting httpurlconnection connection = (httpurlconnection)url.openconnection(); connection.getresponsecode(); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -