What exactly does httpurlconnection.setReadTimeout() do?

According to the java docs of connection.setReadTimeout() –
“A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.”

So if I set a certain read timeout, and start downloading a file, will the download break if the timeout is reached?

Or does it break only when there is nothing to read for that specified timeout?


It’s only raise exception if there is no response. It’ll not break while getting data so don’t worry about.

Leave a Reply

Your email address will not be published. Required fields are marked *