SORU
10 Mayıs 2010, PAZARTESİ


HttpURLConnection zaman aşımı sorusu

Eğer URL, daha sonra 5 saniye bağlanmak için alır eğer yanlış bir dönüş için bu nasıl mümkün kullanarak java? Burada ise bu URL geçerli olup olmadığını kontrol etmek için kullandığım kod

   HttpURLConnection.setFollowRedirects(false);
   HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
   con.setRequestMethod("HEAD");
   return (con.getResponseCode() == HttpURLConnection.HTTP_OK);

CEVAP
10 Mayıs 2010, PAZARTESİ


Bu gibi zaman aşımı ayarlayabilirsiniz

con.setConnectTimeout(connectTimeout);
con.setReadTimeout(socketTimeout);

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • echifitness

    echifitness

    9 Kasım 2008
  • pjtoohot

    pjtoohot

    15 NİSAN 2008
  • Qmusic Romania

    Qmusic Roman

    8 Temmuz 2011