I\'m trying to take a given URL entered by user and determine if the URL is pointing to a image or a video.
Example use case:
When a user paste in the URL o
Issue an HTTP HEAD request so you can examine the HTTP headers that come back without having to first download the entire document. Showing a non-programmatic case under Linux using "curl":
$ curl --head http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png HTTP/1.1 200 OK Cache-Control: max-age=28800 Content-Length: 3428 Content-Type: image/png Last-Modified: Fri, 16 Jan 2009 09:35:30 GMT Accept-Ranges: bytes ETag: "98f590c5bd77c91:0" Server: Microsoft-IIS/7.0 Date: Fri, 23 Jan 2009 03:55:39 GMT
You can see here from the Content-Type that this is an image. You can use HTTPClient from Apache from Java to do the HTTP Head request.
If you want to download the content for sure, then just issue the HTTP GET (using Httpclient) and use the same HTTP Header to determine the content type.