News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

URLConnection getReadTimeout Example

Started by VelMurugan, Dec 19, 2008, 09:14 PM

Previous topic - Next topic

VelMurugan

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

Source : codingdiary