import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
public class HttpClientExample {
public static void main(String[] args) {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://example.com");
try {
int statusCode = client.executeMethod(method);
String response = method.getResponseBodyAsString();
System.out.println("Response Code: " + statusCode);
System.out.println("Response Body: " + response);
} catch (Exception e) {
e.printStackTrace();
} finally {
method.releaseConnection();
}
}
}