Java console error under windows

Following code

System.out.println("Start"); String s = ""; //936 * 5 = 4680 characters for (int i = 0; i < 937; i++){ s += "1234 "; } System.out.println(s); System.out.println("End"); 

creates an empty line between "Start" and "End" in the java console under the windows, but it works as expected when running MacOS or Linux. The same applies when writing to a file instead of using sysout. I tried several window machines. It doesn't matter if I execute the method through eclipse or via cmd.

When you change "1234" to "1234" or "12g4" or when the number of runs is more / less than 936, it works as expected from the entire OS.

Can someone confirm this / is there a known bug in this question?

+6
source share
1 answer

I can also reproduce this in Windows 7. It looks like a limitation due to the OS in SWT, and it looks like it was a very long time (2002). It is designated as WONTFIX. See GC # drawString, drawText does not display more than 10923 characters per line correctly . So this is a known mistake.

The workaround is to go to Workspace-> Preferences-> Run / Debug-> Console and install the fixed-width console as something like 4000 characters. This will wrap your lines after 4000 characters, which is a pain, but at least you get all your result.

I tried Galileo (3.5), Helios (3.6) and Indigo (3.7), and they all show behavior, but, oddly enough, Galileo and Helios have a limit = 818 (4090 characters) and Indigo = 936 (4680) as said OP. 4090 makes me think about the OS limit (the next will be 4090 + 5 + crlf,> 4096), which corresponds to the errors raised in Eclipse / SWT. I can not explain why there is a difference in the number of received characters. I can only assume that this is something in the OS.

There are several duplicate errors in Eclipse:

Everything seems to have been the result: Error 11601 - the console freezes when displaying long lines without crlf

+8
source

Source: https://habr.com/ru/post/902913/


All Articles