<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
public class HttpClientExample {
public static void main(String[] args) {
HttpClient httpClient = new HttpClient();
HttpMethod method = new GetMethod("https://api.example.com/data");
try {
int statusCode = httpClient.executeMethod(method);
String responseBody = method.getResponseBodyAsString();
if (statusCode == 200) {
} else {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
method.releaseConnection();
}
}
}