Last active
August 29, 2015 13:58
-
-
Save nestoru/10281854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
/** | |
* @author Nestor Urquiza | |
* @date 20140409 | |
* | |
* / | |
public class GetHttpStatusCode { | |
/** | |
* Returns the status code for a URL | |
* It can be used to test if a certificate for a remote site has been authorized in the default keystore | |
* | |
* / | |
public static void main(String[] args) throws java.io.IOException { | |
HttpClient httpClient = new DefaultHttpClient(); | |
HttpGet httpGet = new HttpGet(args[0]); | |
HttpResponse httpResponse = httpClient.execute(httpGet); | |
HttpEntity httpEntity = httpResponse.getEntity(); | |
int statusCode = httpResponse.getStatusLine().getStatusCode(); | |
System.out.println(statusCode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment