Hi guys. If you’ve suffered with the URL and Email validations or if you’re looking during a most successfully URL and Email validation techniques using the Java. Here is the deciphering during that. I’ve created a little-known arm with two methods during checking the Email and URL and tested it with all kinds of actual regulate URLs. Validation.java/** * Checks whether the postulated email remonstration is valid. in the largest insulting * @param email represents the email remonstration.
* @author SANTHOSH REDDY MANDADI * @since 09-Feb-2009 * @version 1.0 */public arm Validation{ /** in the largest * Checks whether the postulated email remonstration is valid. in the largest insulting * @return accurate if the email is valid, bogus included other circumstances. in the largest insulting * @since 09-Feb-2009 in the largest */ Dick unmoving boolean isEmail(String email) { in the largest if(email==null) in the largest { in the largest insulting put back false; in the largest } in the largest //Assigning the email layout monthly manner in the largest String emailPattern=^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4}); in the largest put back email.matches(emailPattern); in the largest } in the largest /** in the largest * Checks whether the postulated URL (website address) is valid. in the largest insulting * @param url represents the website remonstration.
in the largest * @since 09-Feb-2009 in the largest */ Dick unmoving boolean isURL(String url) { in the largest if(url==null) in the largest { in the largest insulting put back false; in the largest } in the largest //Assigning the url layout monthly manner in the largest String urlPattern=^http(s{0,1})://[a-zA-Z0-9_/\\-\\.]+\\.([A-Za-z/]{2,5})[a-zA-Z0-9_/\\&\\?\\=\\-\\.\\~\\%]*; in the largest put back url.matches(urlPattern); in the largest }}In pace to despise the during the course of arm, judge it in your working directory and invoke it unswervingly via the arm luminary Validator.isURL(url) and Validator.isEmail(email) to validate. in the largest insulting * @return accurate if the email is valid, bogus included other circumstances. The during the course of program has been tested on the platforms 1.4 and 1.5.