I don't know Java, but in C# I'd read the whole file with
System.IO.File.ReadAllText(String)
then use a RegularExpression.
I definitely would
not use
IndexOf
-- that will lead to false-positives.
For example:
System.Text.RegularExpressions.Regex reg =
new System.Text.RegularExpressions.Regex
( @"(?i)\b(a)|(the)|(this)\b" ) ;
System.Text.RegularExpressions.MatchCollection mat = reg.Matches ( args [ 0 ] ) ;
System.Console.WriteLine ( mat.Count ) ;