thank you for your help, greatly appreciate it but every time I try to run this program i get this error:

Exception in thread "main" java.io.FileNotFoundException: mails.txt (The system
cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.util.Scanner.<init>(Scanner.java:636)
at CheckMail.main(CheckMail.java:12)
Press any key to continue . . .

sure you will get this message;
CHange the name "mails.txt" to the name of your file where you put the data.

the file where each record contains a student's last name (one word only) and email address.

As far as you are concerned with String validation of email addres,
you may use Regular Expression in Java...
eg.

String email = "abcd_09@daniweb.com";
boolean isValidEmail = email.matches("[\\w.]+@[\\w]+\\.[\\w]+");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.