You might want to use the Apache HttpClient Utility.
Add the following maven dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
Next use the following code to hit an URL using HTTP Get method.
//create the url
String url = "http://www.google.com/search?q=httpClient";
//create the http client object
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(url);
//execute the request and capture the response
HttpResponse response = client.execute(request);
//get response code
System.out.println("Response Code : "
+ response.getStatusLine().getStatusCode());
//get the response body
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
//capture the response in string
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
Added benefit is the HttpClient automatically retries hitting the URL if the URL is down. Also, it provides for retry event handlers.
More Reference: Force retry on specific http status code