URLConnection getReadTimeout Example

URLConnection class getReadTimeout example. This example shows you how to use getReadTimeout method.


URLConnection class getReadTimeout example. public int getReadTimeout() Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).

Here is the code
/*
 * @ # GetReadTimeout.java
 * A class repersenting use to GetReadTimeout method 
 * of URL class in java.net package
 * version 24 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetReadTimeout {

    public static void main(String args[]) throws Exception {

        SocketAddress address = new InetSocketAddress("192.168.10.80"9090);
        Proxy proxy = new Proxy(Proxy.Type.HTTP, address);

        URL url = new URL("http://yahoo.com");
        URLConnection connection = url.openConnection(proxy);

        if (connection.getReadTimeout() == 0) {
            System.out.println("Timeout of infinity");
        else {
            System.out.println("read timeout =" + connection.getReadTimeout());
        }
    }
}

Output
Timeout of infinity

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US