Java URLConnection .setReadTimeout (int timeout)
Syntax
URLConnection.setReadTimeout(int timeout) has the following syntax.
public void setReadTimeout(int timeout)
Example
In the following code shows how to use URLConnection.setReadTimeout(int timeout) method.
// w w w.ja v a 2s. co m
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String args[]) throws Exception {
URL u = new URL("http://www.java2s.com");
URLConnection uc = u.openConnection();
uc.setReadTimeout(1000);
System.out.println(uc.getReadTimeout());
}
}
The code above generates the following result.