I am missing a small piece here cant get my head over it,so here i go CONDITION: wherein if one of the column line within the csv file starts with $$PHONE$$ 9 and has another column where COND=x then the value of a string string name="tom" Else if column begins with $$PHONE$$9 and does NOT have a line where it reads COND=X ,then string name="james"
int n = 41; // The line number
String line;
try (BufferedReader br = new BufferedReader(new FileReader(context.tfilelistdir))) {
boolean foundABC = false;
boolean foundXYZ = false;
int i = 0;
while ((line = br.readLine()) != null && i++ < n) {
boolean curroper9= line.startsWith("$$PHONE$$ 9");
oper9 |= curroper9;
boolean currcondmicro=line.contains("COND=X");
condmicro |= currcondmicro;
boolean currcondnotmicro=!line.contains("COND=Microsite");
condnotmicro |= !currcondnotmicro;
//one of the if-blocks
else if (curroper9 && currcondmicro && ( curroper9 || condmicro) )
{
System.out.println("NAME IS TOM");
}
else if (curroper9 && currcondnotmicro && ( curroper9 || currcondnotmicro) )
{
System.out.println("NAME IS JAMES");
}
}
}
How to precisely match my problem statement ,this is tricky coz i am checking for condition that starts with 9 as a digit and matches COND=X ,in my output i am getting both the conditions to be true.
And also wont print just one line of output ,it prints several lines of the same output.How to make it restrictive and accurate?
Aucun commentaire:
Enregistrer un commentaire