You should loop through all the file names args[i] and process them. btw what do
you do with 'words' such as "forkformforum" when you search for the word "for"?
kind regards,
Jos
Hi,
Thank u for correcting my code..
I have altered n now it works fine..
import java.util.Scanner;
import java.io.*;
class Parse{
public static void main(String args[]){
try{
Scanner sc = new Scanner(new File(args[0]));
int count = 0;
while(sc.hasNext()){
String result = (String)sc.next();
if(result.contains("for")){
for(int i=0;i<result.length();){
int j = i+3;
if(j<=result.length()){
if("for".equals(result.substring(i,i+3)))
count++;
}
i=i+3;
}
}
}
System.out.println("count:::::::::"+count);
}catch(Exception e){
e.printStackTrace();
}
}
}
-Thanks 7 Regards,
Hamsa