String url_pattern = "\\b(https?|ftp|file|ldap)://"
+ "[-A-Za-z0-9+&@#/%?=~_|!:,.;]"
+ "*[-A-Za-z0-9+&@#/%=~_|]";
Pattern p = Pattern.compile(url_pattern, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(post.getContent());
// Find all url and do your logic
while (m.find()) {
}
Expand shorten URL: http://www.srccodes.com/p/article/37/expand-shortened-link-using-java
URL Validator:
https://commons.apache.org/proper/commons-validator/