SORU
26 HAZİRAN 2009, Cuma


Nasıl KOYDU göndermek için, HttpURLConnection HTTP isteği SİLMEK?

java.net.HttpURLConnection HTTP-tabanlı, kalıcı olarak SİL (neredeyse) URL göndermek mümkün olup olmadığını bilmek istiyorum.

Pek çok makale, YAZI göndermek için nasıl bir seçim istekleri İZLEME o kadar tarif okudum ama yine de başarılı bir şekilde PUT ve DELETE istekleri yerine getiren herhangi bir örnek kod bulamadım.

CEVAP
26 HAZİRAN 2009, Cuma


Bir HTTP PUT gerçekleştirmek için:

URL url = new URL("http://www.example.com/resource");
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoOutput(true);
httpCon.setRequestMethod("PUT");
OutputStreamWriter out = new OutputStreamWriter(
    httpCon.getOutputStream());
out.write("Resource content");
out.close();
httpCon.getInputStream();

Bir HTTP SİLMEK gerçekleştirmek için:

URL url = new URL("http://www.example.com/resource");
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoOutput(true);
httpCon.setRequestProperty(
    "Content-Type", "application/x-www-form-urlencoded" );
httpCon.setRequestMethod("DELETE");
httpCon.connect();

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • incognitotraveler

    incognitotra

    27 Mayıs 2010
  • Nick Pitera

    Nick Pitera

    8 NİSAN 2006
  • sdasmarchives

    sdasmarchive

    2 HAZİRAN 2010