<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.methods.GetMethod;
public class HttpClientExample {
public static void main(String[] args) {
String url = "http://example.com/api";
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
try {
client.executeMethod(method);
String response = method.getResponseBodyAsString();
System.out.println("Response: " + response);
} catch (Exception e) {
e.printStackTrace();
} finally {
method.releaseConnection();
}
}
}