当前位置: 首页>>代码示例>>Java>>正文


Java EntityUtils.toString方法代码示例

本文整理汇总了Java中cz.msebera.android.httpclient.util.EntityUtils.toString方法的典型用法代码示例。如果您正苦于以下问题:Java EntityUtils.toString方法的具体用法?Java EntityUtils.toString怎么用?Java EntityUtils.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cz.msebera.android.httpclient.util.EntityUtils的用法示例。


在下文中一共展示了EntityUtils.toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
public static Hostplace get(String ip) throws Exception {
    HttpGet httppost = new HttpGet(Geocode.url + "/" + ip);
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = httpclient.execute(httppost);

    // StatusLine stat = response.getStatusLine();
    int status = response.getStatusLine().getStatusCode();

    if (status == 200) {
        HttpEntity entity = response.getEntity();
        String data = EntityUtils.toString(entity);

        JSONObject json = new JSONObject(data);
        if (json.getString("status").equals("fail"))
            throw new Exception();

        Hostplace hostplace = Hostplace.getJson(json);
        return hostplace;
    }
    throw new Exception();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:22,代码来源:Geocode.java

示例2: getBlock

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
public static Block getBlock(String blockhash) throws Exception {
    HttpGet httppost = new HttpGet(Insight.url + "/block/" + blockhash);
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = httpclient.execute(httppost);

    // StatusLine stat = response.getStatusLine();
    int status = response.getStatusLine().getStatusCode();

    if (status == 200) {
        HttpEntity entity = response.getEntity();
        String data = EntityUtils.toString(entity);

        JSONObject json = new JSONObject(data);
        Block block = Block.getJson(json);
        return block;
    }
    throw new Exception();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:19,代码来源:Insight.java

示例3: getBlockHash

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
public static String getBlockHash(String height) throws Exception {
    HttpGet httppost = new HttpGet(Insight.url + "/block-index/" + height);
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = httpclient.execute(httppost);

    // StatusLine stat = response.getStatusLine();
    int status = response.getStatusLine().getStatusCode();

    if (status == 200) {
        HttpEntity entity = response.getEntity();
        String data = EntityUtils.toString(entity);

        JSONObject json = new JSONObject(data);
        String hash = json.getString("blockHash");
        return hash;
    }
    throw new Exception();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:19,代码来源:Insight.java

示例4: getTx

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
public static Tx getTx(String hash) throws Exception {
    HttpGet httppost = new HttpGet(Insight.url + "/tx/" + hash);
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = httpclient.execute(httppost);

    // StatusLine stat = response.getStatusLine();
    int status = response.getStatusLine().getStatusCode();

    if (status == 200) {
        HttpEntity entity = response.getEntity();
        String data = EntityUtils.toString(entity);

        JSONObject json = new JSONObject(data);
        Tx tx = Tx.getJson(json);
        return tx;
    }
    throw new Exception();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:19,代码来源:Insight.java

示例5: performHttpGet

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
public void performHttpGet(String uri, HttpResponseCallback callback) {
    try {
        HttpGet get = new HttpGet(new URI(uri));
        CloseableHttpResponse response = client.execute(get);

        int status = response.getStatusLine().getStatusCode();

        try {
            HttpEntity entity = response.getEntity();
            String json = EntityUtils.toString(entity);
            EntityUtils.consume(entity);

            callback.onHttpResponse(status, json);
        } finally {
            response.close();
        }
    } catch (IOException | URISyntaxException e) {
        callback.onException(e);
    }
}
 
开发者ID:pgrenaud,项目名称:p2p-android-sdk,代码行数:21,代码来源:HttpClientWrapper.java

示例6: execute

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
private JSONObject execute(HttpPost request, JSONObject payload) throws IOException, NetworkException, JSONException {
    setPayloadXsrf(payload);
    request.setEntity(new ByteArrayEntity(payload.toString().getBytes()));
    authenticateRequest(request);

    HttpResponse resp = client.execute(request, httpContext);
    StatusLine sl = resp.getStatusLine();
    if (sl.getStatusCode() != 200) throw new NetworkException(sl);

    return new JSONObject(EntityUtils.toString(resp.getEntity(), Charset.forName("UTF-8")));
}
 
开发者ID:devgianlu,项目名称:PlayConsoleAndroidAPI,代码行数:12,代码来源:PlayConsoleRequester.java

示例7: getHtmlConsolePage

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
private static String getHtmlConsolePage(String dev_acc, CookieStore cookieStore) throws IOException, NetworkException {
    HttpGet get = new HttpGet(Utils.DEVELOPER_CONSOLE_URL + "?dev_acc=" + dev_acc);

    HttpClient client = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();

    HttpResponse resp = client.execute(get);
    StatusLine sl = resp.getStatusLine();
    if (sl.getStatusCode() != 200) throw new NetworkException(sl);

    return EntityUtils.toString(resp.getEntity(), Charset.forName("UTF-8"));
}
 
开发者ID:devgianlu,项目名称:PlayConsoleAndroidAPI,代码行数:12,代码来源:PlayConsoleAuthenticator.java

示例8: getResponseString

import cz.msebera.android.httpclient.util.EntityUtils; //导入方法依赖的package包/类
public static String getResponseString(CloseableHttpResponse closeableHttpResponse,String charset) throws IOException {
    HttpEntity bufferedHttpEntity = closeableHttpResponse.getEntity();
    if(charset == null){
        charset = CHARSET;
    }
    return EntityUtils.toString(bufferedHttpEntity, charset);
}
 
开发者ID:xm0625,项目名称:BaiduPanApi-Java,代码行数:8,代码来源:HttpClientHelper.java


注:本文中的cz.msebera.android.httpclient.util.EntityUtils.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。