URLConnection problem
- From: Marcelo <mache_1999@xxxxxxxxx>
- Date: Wed, 30 Nov 2005 02:49:46 +0100
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). .
- Follow-Ups:
- Re: URLConnection problem
- From: Chris Smith
- Re: URLConnection problem
- Prev by Date: Re: mono-thread concurrent modification
- Next by Date: Re: formatted printing of text- color
- Previous by thread: Question about Stateless Session Beans and creation
- Next by thread: Re: URLConnection problem
- Index(es):