3

Possible Duplicate:
How to detect the presence of URL in a string

Is there a way to find out user entered text is webiste url .

For example if user entered

www.yahoo.com

www.google.fr

can we detect it is a url String ?

thanks

Community
  • 1
  • 1
Ata
  • 12,126
  • 19
  • 63
  • 97

2 Answers2

13
try { URL url = new URL("url_string"); }
catch (MalformedURLException e) { /* invalid URL */ }
waqaslam
  • 67,549
  • 16
  • 165
  • 178
0

Use java.net.URL to detect presence of url in string.

see the following thread :

How to detect the presence of URL in a string

Community
  • 1
  • 1