il setConnectTimeout della HttpURLConnection non è supportato nella versione 1.4.x!!!
In giro ho trovato qualcosa di simile (Apache Commons Http Client), anche se...
codice:
private static String url = "http://www.apache.org/";
public static void main(String[] args) {
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
GetMethod method = new GetMethod(url);
// Provide custom retry handler is necessary
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
System.out.println("Setting time out to 10");
method.getParams().setSoTimeout(10); // Throws IOException on TimeOut.
try {
.....
.....
}
...il metodo getParams() di GetMethod non è implementato (nella 1.4.x). qualcuno potrebbe darmi qualche dritta...