Sunday 15 May 2011

java - Eclipse standard output/error synchronization -


I am running some code and expect to get a specific message sent to Systen.err at one point, But for some reason the reason is coming to the second point here is the code -

  public static zero main (string [] args) exception {system.out.println ("file 1:") Throws; (Generalized Entity Ni: forolution.entities.values ​​()) {System.out.println (NE); } System.out.println ("\ nFile 2:"); For (generalized declaration: submissions.Nenet.values ​​()) {System.out.println (NE); } System.out.println (check ()); } Static String Check () {StringBilder Results String = New StringBuilder (); System.out.println ("Start \ nquot"); (For generalized entity solution entity: theolution.entities.values ​​()) {generalized submissions = thesubmission.entities.get (solutionEntity.name); If (resolution entity instances NormalizedClass) {if (((NormalizedClass of Sbmisnins Institution)) {System.err.println ( "*** WARNING: Smadhanintiti" + Solution + "class but submission Anntiti" + submission Antiti + " Is not "); // This line should be the second position from the last result String.append (called" expected "+ presentation +" class +++ solution ");}} // system Out.printlean ("found:" both in "+ ne +");} return result String.toString ();}   

and here Output -

  *** Warning: Smadhanantiti Class C {x = private Int x, y = private Int y} {C = C {1thParam = int, 2thParam = int}} {getX = int getX {}} is a square, but Sbmisnintiti empty & lt; --------- this line should be at the end of file 1: class C {x = private Int x, y = private Int y} {C = C {1 Viparam = Int, 2THParam = int}} {getX = int getX {}} class Sbsi {z = private Int h} {} {} C D Double D F {} Int come Sbsi Sbsi File 2: Class D {x = Private IX, Y = Private Entity} {D = D {1 Vipiarm = Int, 2THParam = int}} {getX = int getX {}} class lesson {z = private Int FRD} {} {} DC Double D Int F {} Int I class to begin investigating Sbsi Sbsi C { X = private int x, y = private int y} {C = C {1thParam = int, 2thParam = int}} Now the first line of output on the basis of the code should be final second line. However, when I run it in the eclipse, then it comes as the first line, why is it so? I have also noticed that if I change from  System.err  to  System.out  then it comes as expected. So it seems that Eclipse collects all the error output first and then relates to the standard output?   

write two separate streams naturally out of order performance, however, Systemkout .println should be automatically flush with each call, which means that the situation you are seeing should not be possible, or be able to reduce the worst position with synchronization.

Unfortunately, a bug in the eclipse is actually working properly by preventing it and the order lines you are seeing are being taken out: < P> If you want to consider using log-in log-in (+ SLF4J if desired), you may be allowed to log in to various levels of messages while maintaining a consistent command.

No comments:

Post a Comment