httpclientUtils

来源:互联网 发布:管家婆软件下载试用 编辑:程序博客网 时间:2024/05/22 01:34
package com.example.utils;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class GetWroldUtils {

    public static String GetWroldUtils1(String path) {
        HttpClient client=new DefaultHttpClient();
        HttpGet get=new HttpGet(path);
        try {
             HttpResponse execute = client.execute(get);
             if(execute.getStatusLine().getStatusCode()==200){
                 return EntityUtils.toString(execute.getEntity());
             }
        } catch (Exception e) {
        e.printStackTrace();
        }
        return null;
    }
}

0 0