|
Java™ by example!
|
|
|
How do I check for errors when connecting to a URL?
You can use the response codes that are provided in the HttpURLConnection class. The idea is send the HEAD request instead of the (default) GET command and read out the error code (HTTP_OK = generally ok URL). The following example shows how this is realized. When run as an application, it will also follow redirects (setFollowRedirects(true)). An applet is not allowed to change this variable.
returns:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|