Following is the code i am using:
Its always giving me output "Invalid email address"
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String name="";
do
{
System.out.println("Email:");
String email= br.readLine();
if(!name.matches("^[a-zA-Z0-9]+@[a-zA-Z0-9]+(.[a-zA-Z]{2,})$"))
System.out.println("Invalid email address");
else
break;
}while(true);