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

