httpclient的用法

GetMethod get = new GetMethod("#the url");
try {
    HttpClient client = new HttpClient();
    client.executeMethod(get);
    String ret = get.getResponseBodyAsString();
    if(ret.startsWith("ok")) {
        return true;
    }else {
        log.warn("not ok");
        return false;
    }
}catch(Exception e) {
    return true;
}finally {
    if(null != get) {
        get.releaseConnection();
    }
}

你可能感兴趣的:(httpclient)