What is the default timeout for URL
in Java?
How does this affect url.openStream()?
There are two types of timeouts: connection timeout
and read timeout
.
Default will be -1 (infinity)
for connection timeout and read timeout.
openStream()
makes connection and provides input stream so openStream()
will have impact from connection timeout and read timeout.
The following code in JDK explains this:
package sun.net
public class NetworkClient {
/* Default value of read timeout, if not specified (infinity) */
public static final int DEFAULT_READ_TIMEOUT = -1;
/* Default value of connect timeout, if not specified (infinity) */
public static final int DEFAULT_CONNECT_TIMEOUT = -1;
...
}