My DB generates 3000 lines for each process and I must count some values for a report.
the generated file is like this :
CREATE TTL:NAME=SMO:0/TTS:0/UPL:1,BLQ=TRUE,NAND:TRUE,EBSPWRC=ADAPTIVE,EMSPWRC=ADAPTIVE
CREATE GPL,ASSLAPD=TSM:37/LPDLM:0,
CREATE GPL,ASSLAPD=TSM:38/LPDLM:5,
CREATE GPL,ASSLAPD=TSM:41/LPDLM:1,
CREATE GPL,ASSLAPD=TSM:21/LPDLM:8,
CREATE TTL:NAME=SMO:0/TTS:0/UPL:1,BLQ=FALSE,NAND:FALSE,EBSPWRC=ADAPTIVE,EMSPWRC=ADAPTIVE
CREATE GPL,ASSLAPD=TSM:37/LPDLM:4,
CREATE GPL,ASSLAPD=TSM:21/LPDLM:1,
CREATE TTL:NAME=SMO:0/TTS:0/UPL:1,BLQ=TRUE,NAND:TRUE,EBSPWRC=ADAPTIVE,EMSPWRC=ADAPTIVE
CREATE GPL,ASSLAPD=TSM:38/LPDLM:1,
CREATE GPL,ASSLAPD=TSM:41/LPDLM:1,
CREATE GPL,ASSLAPD=TSM:21/LPDLM:7,
Actually I want to count CREATE GPL if the BLQ and NAND be true,
Also I wrote this method that read the file line by line :
public void getGPLCount(File f) throws Exception {
BufferedReader br = new BufferedReader(new FileReader(f));
String line;
while ((line = br.readLine()) != null) {
if (line.startsWith("CREATE TTL:NAME=") && line.contains("BLQ=TRUE") && line.contains("NAND:TRUE"))
//___//
}
}
thnaks for your help …
It appears as if Thomas’s answer is close, but misunderstood what you wanted. I’m just modifying his snippet.
Something like this:
So start counting every time we get BOTH BLQ=true AND Nand=true, and stop the counter if we get a TTL line missing one (or both) of those. Is this the logic you want?
UPDATE:
Matthew’s solution is also correct, but in pseudocode. Translating to Java:
His answer is cleaner because he doesn’t duplicate the
startsWith("CREATE TTL:NAME=")like I did. In my defense, I was trying to get you a working java example and Thomas was extremely close to what you wanted.