I wrote a piece of code to look through a String named line with several lines(hence newline characters) in it. my code prints all locations of the string Context in the line. how do i modify the code to print the occurence
String Context = ("[020t");
int index =0;
int count = 0;
while((index = line.indexOf(Context, index))!= -1)
{
count++;
index += Context.length() -1;
System.out.println(index);
}
System.out.println(count);
A sample line is
[020t 12:23:43 FILE TAKEN
[020t 12:23:44 REGISTRATION END
[0r(1)2[000p[040qe1w3h162[020t*881*11/11/2010*12:24*
*CARD INSERTED*
[020t 12:24:06 CODE ENTERED
11\11\10 12:24 10390011
5061180101607659013 6598
INVALID TRANSACTION, PLEASE CONTACT
YOUR ADMINISTRATOR FOR ADVICE
I intend to pass the lines out to another method. Thanks