Here you can find the source of getResponseCode(URL url)
Parameter | Description |
---|---|
url | represents web address to check |
Parameter | Description |
---|---|
Exception | an exception |
public static int getResponseCode(URL url) throws Exception
//package com.java2s; import java.net.HttpURLConnection; import java.net.URL; public class Main { /**//from w w w.j a v a 2 s . c o m * returns response status code for specified URL * * @param url represents web address to check * @return response code for specified URL * @throws Exception */ public static int getResponseCode(URL url) throws Exception { HttpURLConnection.setFollowRedirects(false); HttpURLConnection huc = (HttpURLConnection) url.openConnection(); return huc.getResponseCode(); } }