简体   繁体   中英

Statements ignored outside while loop?

Hello this problem has been bugging me since a week I searched everywhere in vain. I have this code ................

while ((str = buff.readLine()) != null) {
    String[] line = str.split(";");
    String part1 = line[0];
    String part2 = line[1];
    String part3 = line[2];
    String part4 = line[3];
    String part5 = line[4];

    if (c.equals(part3)) {
        st = st + part1 + ";" + part2 + ";" + part3 + ";" + part4 + ";" + part5;
        System.out.println(part1 + ";" + part2 + ";" + part3 + ";" + part4 + ";" + part5 + "\n");

        fich1_tampon.write(st);
        fich1_tampon.flush();
        fich1_tampon.newLine();

        ++i;
    }
}

System.out.println("F;" + i);
fich1_tampon.close();
buff.close();
}

the "System.out.println("F;" + i);" is ignored I don't know why. The code is very long but basically I'm looking for lines that have a certain String that was put in c and I'm writing those line in another file. The result on my consoleis like this :

E;2014/02/19 20:21:06 File already exists. N;2000;PU;Promotion iphone;232425

N;2001;PU;Promotion dell;232426

N;2002;PU;Promotion samsung;23242

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at LireFichierDecouper.decouper(LireFichierDecouper.java:70) at Main2.main(Main2.java:7) Line 70 in LireFichierDecouper is "String part3 = line[2];"

PS:I'm very very new to java and eclipse, if you want me to post all the code to make it more clear I will.

  • If you work on eclipse , check " Problems " view for errors. Sometimes eclipse cannot compile code when your workspace has errors.

  • If you work on a running server , may be server do not recognize your changes. Restart it, may be this helps.

  • If double of above do not help you please explain exactly what you want and specify your development environment how it is.

A debugger would be helpful to see if you are reaching that code by adding a break point at the System.out.println. Also, where are you running the code? System.out.println would go where directed depending on how java is run. Please provide the command line if executing from the command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM