Please help me regarding email validation using simple core java

Hi i have to validate the email but im using simple core java i have written code like this its working fine but it fails in one senario like it accepting special characters after @ symbol but its not desirable here im sending the code plz give me reply....

<code>

public boolean echeck(String str) {

String at = "@";

String dot = ".";

int lat = str.indexOf(at);

int lstr = str.length();

if (str.indexOf(at) == -1) {

return false;

}

if ((str.indexOf(at) == -1) || (str.indexOf(at) == 0)

|| (str.indexOf(at) == lstr)) {

return false;

}

if ((str.indexOf(dot) == -1) || (str.indexOf(dot) == 0)

|| (str.indexOf(dot) == lstr)) {

return false;

}

if (str.indexOf(at, (lat + 1)) != -1) {

return false;

}

if (str.substring(lat - 1, lat).equals(dot)

|| str.substring(lat + 1, lat + 2).equals(dot)) {

return false;

}

if (str.indexOf(dot, (lat + 2)) == -1) {

return false;

}

if (str.indexOf(" ") != -1) {

return false;

}

return true;

}

</code>

Regard's

Rajani

[1178 byte] By [rajnikanthgoldstonea] at [2007-11-27 2:29:03]
# 1
for such cases, you have to use class regexp and Patternyou can use Pattern.matches(String regexp, String emailEntered) to check if email is correcti think the regexp of a mail address can be found on google
calvino_inda at 2007-7-12 2:41:46 > top of Java-index,Java Essentials,Java Programming...
# 2
I dont know how to use regex plz give me some code to validate email idRegardsRajani
rajnikanthgoldstonea at 2007-7-12 2:41:46 > top of Java-index,Java Essentials,Java Programming...
# 3
What is wrong with the suggestions here: http://forum.java.sun.com/thread.jspa?threadID=5165170&messageID=9631380#9631380
mlka at 2007-7-12 2:41:46 > top of Java-index,Java Essentials,Java Programming...