• Post Reply Bookmark Topic Watch Topic
  • New Topic

Validating URLs

 
Neil Hainer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anyone suggest how I can go about validating URLs? It appears that the JDK only throws MalformedURLException if the URL contains an undefined protocol (scheme). I tried the Apache Commons-Validator API which seemed to do the same thing. I want to make sure the rest of the URL is valid as well.

TIA,

Neil
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to read some bytes from the url.
 
Neil Hainer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for responding. Unfortunately (without going into the detail)this approach is not an option. I actually need to examine the URL and determine if it's format is legit without attempting to read from it. Otherwise this would be a good solution for me.

Thanks again,

Neil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!