I also had a same issue when I had to do it for the first time. Here is code that can help you to validate email in Java programming language.
Code:
package temp;
public class valmail
{
private String eid="";
public valmail(String eid)
{
this.eid = eid;
}
public boolean chk()
{
if (eid == null)
return false;
if(eid.equals(""))
return false;
int pos1 = eid.indexOf("@");
int pos2 = eid.indexOf("@",pos1+1);
if (pos2>=0)
return false;
int pos1a = eid.indexOf(".");
int pos2a = eid.indexOf(".",pos1a+1);
if (pos2a>=0)
return false;
return true;
}
}
You can edit the code to fit to your project's requirement. Best of Luck.
Bookmarks