How do I scan a text file for certain characters in java? -


i have take text file:

ulric schwartz ullamcorper@quisque.ca fringilla donec pc urna convallis erat jesse conrad nunc@eunulla.edu magna praesent interdum incorporated et netus           et ethan eaton cursus@nullam.co.uk sed consequat auctor institute posuere    vulputate lacus griffin stephenson habitant@mattis.com purus sapien institute auctor non  feugiat alan howell lorem@penatibusetmagnis.com mi limited non sollicitudin sawyer stokes ornare@utmiduis.com ut institute nibh phasellus nulla nigel sanford adipiscing@euerat.org lacus varius corp integer vitae nibh 

and scan email addresses, meaning @ followed atleast 3 characters, period, , atleast 2 more characters. understand how scan file:

while(fscan.hasnext()) {     //scan emails goes in here } 

but i'm not sure how scan email. have:

import java.io.*; import java.util.scanner;  public class lab11_emena {      public static void main(string[] args)     {    scanner cscan = new scanner(system.in);    system.out.println("please enter file name.");    string filename = " ";    filename= cscan.nextline();     file infile = new file(filename);               if(!infile.exists())             {             system.out.println("file " + filename + " not exist.");             system.exit(0);             }              scanner fscan =  new scanner(infile);//i getting error      here? saying infile thrown  system.out.println("opened file " + filename);        }     } 

you must use scanner read characters. check different requirements each thing @ character. if char=="@" continue looking other requirements. make go forwards , backwards, untill finds spaces @ either end of email, can import of characters between them.


Popular posts from this blog

html/hta mutiple file in audio player -

debugging - Reference - What does this error mean in PHP? -