SORU
24 NİSAN 2011, Pazar


Nasıl Java'da bir string olarak http yanıtı bir vücut alabilirim?

Burada belirtildiği gibi apache commons onu almak için bir yol vardı biliyorum: http://hc.apache.org/httpclient-legacy/apidocs/org/apache/commons/httpclient/HttpMethod.html ve burada bir örnek:

http://www.kodejava.org/examples/416.html

ama bu önerilmiyor inanıyorum. Bir java http get isteği yapmak ve bir dize olarak yanıt gövde elde etmek için başka bir yol ve bir dere değil mi?

CEVAP
6 Aralık 2012, PERŞEMBE


Burada benim üzerinde çalıştığım proje iki örnek.

  1. EntityUtils HttpEntity

    HttpResponse response = httpClient.execute(new HttpGet(URL));
    HttpEntity entity = response.getEntity();
    String responseString = EntityUtils.toString(entity, "UTF-8");
    System.out.println(responseString);
    
  2. BasicResponseHandler kullanarak

    HttpResponse response = httpClient.execute(new HttpGet(URL));
    String responseString = new BasicResponseHandler().handleResponse(response);
    System.out.println(responseString);
    

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • FattySpins's channel

    FattySpins's

    17 Mayıs 2009
  • Hidden Wolf TV

    Hidden Wolf

    1 EKİM 2009
  • PCDIY

    PCDIY

    16 AĞUSTOS 2013

İLGİLİ SORU / CEVAPLAR