M
Marcelo
Dear Java Programmers,
I am just getting crazy with this stuff.
I am asking for the length of a URLConnection, but sometimes the given URLOject has no information or the address doesn't exists.
URL url = new URL("http://www.alientech.to/pic/exelixis03/Auto-Exelixis_045.JPG");
URLConnection connection = url.openConnection();
//Then we ask for the length
int length = connection.getContentLength();
However, if the host is unknown the application stops in the last line without giving a time out. I have tried with a connection.setConnectTimeout(5000); but I still have the same problem.
How Can I test the validity of a URL (something like a ping) without being blocked?
If I am blocked with a URLConnection, how can interrumpt the channel ? Or even better, is it possible to close the "port" of this URLConnection ?
thanks a lot,
Marcelo
PS: I have already tried to make connection=null, but that doesn't work (the channel is still active).
I am just getting crazy with this stuff.
I am asking for the length of a URLConnection, but sometimes the given URLOject has no information or the address doesn't exists.
URL url = new URL("http://www.alientech.to/pic/exelixis03/Auto-Exelixis_045.JPG");
URLConnection connection = url.openConnection();
//Then we ask for the length
int length = connection.getContentLength();
However, if the host is unknown the application stops in the last line without giving a time out. I have tried with a connection.setConnectTimeout(5000); but I still have the same problem.
How Can I test the validity of a URL (something like a ping) without being blocked?
If I am blocked with a URLConnection, how can interrumpt the channel ? Or even better, is it possible to close the "port" of this URLConnection ?
thanks a lot,
Marcelo
PS: I have already tried to make connection=null, but that doesn't work (the channel is still active).