Behavior confirmed. Strange, must have something to do with the eclipse wrapped output stream. Eclipse 3.5 by me. Perhaps the internal buffering throws away output if it is not properly flushed() or too wide for a line.
package tests;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
public class EclipsePrint {
public static void main(String[] args) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream out = System.out;
System.setOut(new PrintStream(new BufferedOutputStream(bout), true));
System.out.print("start: ");
for (int i = 0; i < 10000; i++) {
// if (i > 1000 && i < 1010)
System.out.print(i + " ");
}
System.out.println("finish");
out.println(bout.size());
out.println(bout.toString());
bout = new ByteArrayOutputStream();
System.setOut(new PrintStream(new BufferedOutputStream(bout), true));
System.out.print("start: ");
for (int i = 0; i < 1000; i++) {
// if (i > 1000 && i < 1010)
System.out.print(i + " ");
}
System.out.println("finish");
out.println(bout.size());
out.println(bout.toString());
}
}
There is a console settings at Run/Debug:Console:console buffer size (characters)
in eclipse which allows you to use up to 10^6 chars as console buffer. Your first loop exceeds it.