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


Java BufferedHttpEntity.getContent方法代码示例

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


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

示例1: HttpGet

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
public static ByteArrayBuffer ʻ(String paramString)
{
  HttpGet localHttpGet = new HttpGet(paramString);
  DefaultHttpClient localDefaultHttpClient = ˊ();
  BufferedHttpEntity localBufferedHttpEntity = new BufferedHttpEntity(localDefaultHttpClient.execute(localHttpGet).getEntity());
  BufferedInputStream localBufferedInputStream = new BufferedInputStream(localBufferedHttpEntity.getContent());
  ByteArrayBuffer localByteArrayBuffer = new ByteArrayBuffer(50);
  while (true)
  {
    int i = localBufferedInputStream.read();
    if (i == -1)
      break;
    localByteArrayBuffer.append((byte)i);
  }
  localBufferedInputStream.close();
  localBufferedHttpEntity.consumeContent();
  localDefaultHttpClient.getConnectionManager().shutdown();
  return localByteArrayBuffer;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:„Ä≥.java

示例2: getStreamFromNetwork

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
@Override
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
	HttpGet httpRequest = new HttpGet(imageUri);
	HttpResponse response = httpClient.execute(httpRequest);
	HttpEntity entity = response.getEntity();
	BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
	return bufHttpEntity.getContent();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:HttpClientImageDownloader.java

示例3: getSideBar

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
private String getSideBar(String subreddit) throws IOException {
    //noinspection deprecation
    @SuppressWarnings("deprecation") HttpClient client = new DefaultHttpClient();
    URL url = null;
    try {
        url = new URL("http://www.reddit.com/r/" + subreddit + "/about/edit.json");
        HttpGet httpGet = new HttpGet(String.valueOf(url));
        //noinspection deprecation,deprecation
        client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("User-Agent: LGG Bot (by /u/amdphenom"));
        httpGet.addHeader("Cookie", "reddit_session=" + user.getCookie());
        httpGet.addHeader("uh", user.getModhash());

        HttpResponse response = client.execute(httpGet);

        HttpEntity ht = response.getEntity();

        BufferedHttpEntity buf = new BufferedHttpEntity(ht);

        InputStream is = buf.getContent();

        BufferedReader r = new BufferedReader(new InputStreamReader(is));

        StringBuilder total = new StringBuilder();
        String line;
        while ((line = r.readLine()) != null) {
            total.append(line);
        }
        System.out.println(total.toString());
        return total.toString();

    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Sidebar download failed");
    }
    return ("fail");
}
 
开发者ID:jaredkaczynski,项目名称:LGSubredditHelper,代码行数:37,代码来源:SidebarUpdater.java

示例4: downloadImage

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
public static Bitmap downloadImage(String url) {

		HttpParams hparams = new BasicHttpParams();
		/**
		 * You can also add timeouts to the settings menu in a real project
		 */
		HttpConnectionParams.setConnectionTimeout(hparams, 10000);
		HttpConnectionParams.setSoTimeout(hparams, 10000);
		HttpGet get = new HttpGet(url);
		DefaultHttpClient client;
		try {
			if (doAcceptAllSSL)
				client = (DefaultHttpClient) SSLErrorPreventer
						.setAcceptAllSSL(new DefaultHttpClient(hparams));
			else
				client = new DefaultHttpClient(hparams);
			HttpResponse response = null;
			if (doUseCookie) {
				CookieStore store = client.getCookieStore();
				HttpContext ctx = new BasicHttpContext();
				store.addCookie(Utils.sessionCookie);
				ctx.setAttribute(ClientContext.COOKIE_STORE, store);
			}
			response = client.execute(get);
			network_response = response.getStatusLine().toString();
			MainActivity.tmpResponseForUIDownload = network_response;
			HttpEntity responseEntity = response.getEntity();
			BufferedHttpEntity httpEntity = new BufferedHttpEntity(
					responseEntity);
			InputStream imageStream = httpEntity.getContent();

			return BitmapFactory.decodeStream(imageStream);

		} catch (Exception ex) {
			ex.printStackTrace();
			return null;
		}
	}
 
开发者ID:mingyuan-xia,项目名称:AppPerfBenchmark,代码行数:39,代码来源:AsyncImageLoader.java

示例5: doInBackground

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
@Override
protected String doInBackground(String... params) {

  // @BadSkillz codes with same changes
  try {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(params[0]);
    HttpResponse response = httpClient.execute(httpGet);
    HttpEntity entity = response.getEntity();

    BufferedHttpEntity buf = new BufferedHttpEntity(entity);

    InputStream is = buf.getContent();

    BufferedReader r = new BufferedReader(new InputStreamReader(is));

    StringBuilder total = new StringBuilder();
    String line;
    while ((line = r.readLine()) != null) {
      strURLList.add(line);
      total.append(line + "\n");
    }
    String result = total.toString();
    Log.i("Get URL", "Downloaded string: " + result);
    return result;
  } catch (Exception e) {
    Log.e("Get Url", "Error in downloading: " + e.toString());
  }
  return null;
}
 
开发者ID:krudayakumar,项目名称:mahaperiyavaapp,代码行数:31,代码来源:Dashboard.java

示例6: getStreamFromNetwork

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
@Override
protected InputStream getStreamFromNetwork(URI imageUri, Object extra) throws IOException {
	HttpGet httpRequest = new HttpGet(imageUri.toString());
	HttpResponse response = httpClient.execute(httpRequest);
	HttpEntity entity = response.getEntity();
	BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
	return bufHttpEntity.getContent();
}
 
开发者ID:jixieshi999,项目名称:juahya,代码行数:9,代码来源:HttpClientImageDownloader.java

示例7: fetch

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
protected InputStream fetch(ImageUrlRequest imageUrlRequest) throws MalformedURLException, IOException {
	DefaultHttpClient httpClient = new DefaultHttpClient();
	ImageToLoadUrl imageToLoadUrl = imageUrlRequest.getImageToLoadUrl(); 
	httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY,
			new UsernamePasswordCredentials(imageToLoadUrl.getUsername(), imageToLoadUrl.getPassword()));
	HttpResponse response = httpClient.execute(new HttpGet(imageToLoadUrl.getUrl()));
	int statusCode = response.getStatusLine().getStatusCode();
	String reason = response.getStatusLine().getReasonPhrase();
	if(statusCode > 299) {
		throw new HttpResponseException(statusCode, reason);
	}
	BufferedHttpEntity entity = new BufferedHttpEntity(response.getEntity());
	return entity.getContent();
}
 
开发者ID:rahulbudhiraja,项目名称:HorizontalImageScroller-Modified,代码行数:15,代码来源:ImageCacheManager.java

示例8: FetchUserProfile

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
private Bitmap FetchUserProfile(Context context, Long userId)
{
    Bitmap profileImage = null;

    // Setup HTTP Request
    GetCookie getCookie = new GetCookie();
    DefaultHttpClient httpClient = getCookie.FetchHttpClient(context);
    HttpGet get = new HttpGet("https://rally1.rallydev.com/slm/profile/viewThumbnailImage.sp?tSize=150&uid=" + userId);
             Log.d("GetUser", "https://rally1.rallydev.com/slm/profile/viewThumbnailImage.sp?tSize=150&uid=" + userId);

    // Setup HTTP Headers / Authorization
    get.setHeader("Accept", "application/json");
    get = ClientInfo.addHttpGetHeaders(get);
    get.setHeader("Authorization", Preferences.getCredentials(context));
    try {
        // Make HTTP Request
        HttpResponse response = httpClient.execute(get);
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() == HttpURLConnection.HTTP_OK) {
            BufferedHttpEntity bufferedHttpEntity = new BufferedHttpEntity(response.getEntity());
            InputStream imageStream = bufferedHttpEntity.getContent();
            profileImage = BitmapFactory.decodeStream(imageStream);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return profileImage;
}
 
开发者ID:PaitoAnderson,项目名称:SkrumazAndroid,代码行数:30,代码来源:GetUser.java

示例9: getStreamFromNetwork

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
@Override
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
    HttpGet httpRequest = new HttpGet(imageUri);
    HttpResponse response = httpClient.execute(httpRequest);
    HttpEntity entity = response.getEntity();
    BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
    return bufHttpEntity.getContent();
}
 
开发者ID:RincLiu,项目名称:Roid-Library,代码行数:9,代码来源:HttpClientImageDownloader.java

示例10: GetDailyScripture

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
public static String GetDailyScripture() throws DailyScriptureReadException
{
    final ArrayList<String> fileLines = new ArrayList<>();
    try {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                Looper.prepare();
                URL url = null;
                try {
                    DefaultHttpClient httpclient = new DefaultHttpClient();
                    HttpGet httppost = new HttpGet("http://godispower.us/DailyVerses/dv" + GetDay() + ".txt");
                    HttpResponse response = httpclient.execute(httppost);
                    HttpEntity ht = response.getEntity();
                    BufferedHttpEntity buf = new BufferedHttpEntity(ht);
                    InputStream is = buf.getContent();
                    BufferedReader r = new BufferedReader(new InputStreamReader(is));
                    StringBuilder total = new StringBuilder();
                    String line;
                    while ((line = r.readLine()) != null) {
                        fileLines().add(line);
                    }
                    String finalString = "Today's verse: ";
                    for (String files:fileLines())
                    {                       //01234567
                        if (files.startsWith("Verse"))
                        {
                            finalString += "<b>" + parseJson(files.substring(8)) + "</b><br>";
                        }
                    }
                    setStr(finalString);
                    Book.DSFinished = true;
                } catch (Exception e) {
                    e.printStackTrace();
                    setStr(":( Couldn't read scripture");
                }
            }
        });
        t.start();
        while (!Book.DSFinished)
        {

        }
        return finalStr() + fileLines().get(0);
    } catch(Exception ex) {
        throw new DailyScriptureReadException(ex);
    }
}
 
开发者ID:apotter96,项目名称:PowerOfGod,代码行数:49,代码来源:DailyScripture.java

示例11: doInBackground

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
@Override
protected String doInBackground(Void... voids) {
  try {
    final JSONObject outJson = new JSONObject();
    final JSONObject catlog  = new JSONObject(Collections.singletonMap("content", paste));
    final JSONObject files   = new JSONObject();
    files.put("cat.log", catlog);
    outJson.put("files", files);
    outJson.put("public", false);

    HttpPost request = new HttpPost(API_ENDPOINT);

    request.setEntity(new ByteArrayEntity(outJson.toString().getBytes()));

    HttpClient   httpclient = new DefaultHttpClient();
    HttpResponse response   = httpclient.execute(request);

    HttpEntity         entity        = response.getEntity();
    BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
    InputStream        input         = bufHttpEntity.getContent();

    BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"), 8);
    StringBuilder  sb     = new StringBuilder();

    String line;
    while ((line = reader.readLine()) != null) {
      sb.append(line).append("\n");
    }

    String     responseBody = sb.toString();
    JSONObject element      = new JSONObject(responseBody);

    if (element.has("html_url")) {
      final String url = element.getString("html_url");
      if (!TextUtils.isEmpty(url)) {
        return url;
      }
    }

    throw new IOException("Gist's response was malformed");

  } catch (IOException | JSONException e) {
    Log.w("ImageActivity", e);
  }
  return null;
}
 
开发者ID:signalapp,项目名称:libpastelog,代码行数:47,代码来源:SubmitLogFragment.java

示例12: openHttpGet

import org.apache.http.entity.BufferedHttpEntity; //导入方法依赖的package包/类
/**
 * Creates Http Request-Client-Response-Entity-BufferedHttpEntity and flows
 * them into InputStream
 * 
 * @param link
 * @return stream from that to read answer to request
 * @throws IOException
 * @throws URISyntaxException
 */
public InputStream openHttpGet(final String link) throws IOException, URISyntaxException {
	httpRequest.setURI(new URI(link));
	final HttpClient httpclient = new DefaultHttpClient();
	final HttpResponse response = httpclient.execute(httpRequest);
	final HttpEntity entity = response.getEntity();
	final BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
	return bufHttpEntity.getContent();
}
 
开发者ID:AvaPirA,项目名称:ColourMate,代码行数:18,代码来源:HttpGetter.java


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