Hello everyone
I have a dynamic big File and I want check a Boolean value and then if it's true, get count of a thing
please help me
for example this is my file (it maybe has 20000 lines)
.
.
.
fsfds fdsfsdf gfhgfh value1=true fdsfd fdfdsr ewref
dfdfsd dsfds dfdf fdsfsd
dfdfsd dsfds myval dfdf fdsfsd
dfdfsd dsfds dfdf fdsfsd
dfdfsd dsfds myval dfdf fdsfsd
fdfdfddsfds
fdfdsfdfdsfdfdsfsdfdsfdsfdsfds
.
.
.
I wrote this code to handle it but I can't because in this case I read Line by Line and I must check if value1 is true then in 2 line after I must count myval ...
public void countMethod() {
int i = 0; //count
try {
BufferedReader input =
new BufferedReader(new FileReader(new File("I:\\1.txt")));
String line;
while ((line = input.readLine()) != null) {
if (line.substring(line.indexOf("value1")).split("=")[1].equals("true")) {
if (line.indexOf("myval") != -1)
i++;
}
}
input.close();
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println("Count is : " + i);
}
How can I check condition and after that if it's true I count myvals?
Thanks a lot