I currently have the following:
int noOfRPs = 3;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(getAssets().open("wifi_log")));
// There are 3 RP's
for (int RP = 0; RP < noOfRPs; ++RP){
String line;
while ((line = br.readLine()) != null){
String pattern = "^RP" + RP;
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(line);
if (m.find())
System.out.println("match = " + line);
}
}
}
catch (IOException e){
System.out.println("IO Error, no file found");
e.printStackTrace();
}
I want to match the patterns: RP0 then RP1 and finally RP2 in my text file. However at the moment, it is continuously matching RP0 despite me changing the variable pattern on each run of the for loop...
Would anyone know what is happening here?
Thanks for your help.
RP0.. the second timeRP1and the third timeRP2.