Reputation: 21
I have written a program to download a file in java. Now i need to search for a string in that file and if the search is true it should notify through email. And furthermore have to schedule this program.. Needed Help
Upvotes: 2
Views: 8953
Reputation: 13799
For searching file you can do something like this:
Scanner s=new Scanner(System.in);
boolean containsString=false;
System.out.println("Enter string to search :");
String searchWrd=s.next();
Scanner readFile =new Scanner(new File("/../fileName"));//enter appropriate file location
readFile.useDelimiter("\\s+");
while(readFile.hasNext())
if(searchWrd.equals(readFile.next()))
{
containsString=true;
break;
}
if(containsString)
System.out.println("Contains searched word");
else
System.out.println("Doesnot contain searched word");
and for mailing you can consider JavaMail.I didn't understand what is meant by scheduling.
Upvotes: 2
Reputation: 1503419
Well, you've got several different tasks there:
Focus on one problem at a time. If you get stuck on one problem, ask a specific question here, saying what you've done so far (but only related to that single problem) and where you're stuck.
Upvotes: 5