Windows下的Java控制台错误 [英] Java console bug under windows

查看:126
本文介绍了Windows下的Java控制台错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码

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");

在Windows控制台下的开始和结束之间生成一个空行,正如运行MacOS或Linux时所预期的那样。同样适用于写入文件而不是使用sysout。我试过多个windows机器。

produces an empty line between "Start" and "End" on the java console under windows, but works as expected when running MacOS or Linux. Same applies when writing to a file instead of using sysout. I've tried multiple windows machines. It doesn't matter whether I execute the method through eclipse or via cmd.

当您将1234更改为1234或12g4时,或者当数字的运行次数多于/少于936次,它与所有操作系统一样正常工作。

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

任何人都可以确认/是否有与此问题相关的已知错误?

Can anybody confirm this/is there a known bug concerning this issue?

推荐答案

我可以重现这一点,在Windows 7。它看起来像一个限制,由于操作系统在SWT,它似乎已经存在了很长一段时间(2002年)。它被标记为WONTFIX。请参见 GC#drawString,drawText不能正确地每行显示超过10923个字符 a>。这是一个已知的错误。

I can reproduce this as well, under Windows 7. It looks like a limitation due to the OS in SWT, and it seems to have been around for a very long time (2002). It's marked as WONTFIX. See GC#drawString, drawText don't render more than 10923 characters per line correctly. So this is a known bug.

解决方法是去工作区 - >首选项 - >运行/调试 - >控制台,并设置固定宽度控制台像4000字符。这将是你的行后4000字符,这是一个痛苦,但至少你会得到你的所有输出。

The workaround is to go to the Workspace->Preferences->Run/Debug->Console and set the Fixed width console to be something like 4000 chars. This will wrap your lines after 4000 characters, which is a pain, but at least you'll get all of your output.

我试过Galileo(3.5),Helios (3.6)和靛蓝(3.7),并且都表现出行为,但更加奇怪的是,伽利略& Helios有一个limit = 818(4090 chars)和indigo = 936(4680)字符作为OP说。 4090让我想到一个操作系统限制(下一个将是4090 + 5 + crlf,> 4096),这与Eclipse / SWT中引发的错误相匹配。我不能解释为什么在接受的字符数有差别。我只能建议它是在操作系统中的东西。

I have tried Galileo (3.5), Helios (3.6) and Indigo (3.7), and all exhibit the behaviour, but wierdly, Galileo & Helios have a limit = 818 (4090 chars) and Indigo = 936 (4680) chars as the OP said. The 4090 makes me think of a OS limit (the next would be 4090 + 5 + crlf, > 4096), which matches with the bugs raised in Eclipse/SWT. I can't explain why there is a difference in the number of characters accepted. I can only suggest that it's something in the OS.

Eclipse中有一些重复的错误:

There are a number of duplicate bugs raised in Eclipse:


  1. 错误19850 - 大字符串打印在控制台overstrikes /根据长度而消失

  2. 错误44866 - 在变量视图中截断长字符

  3. 错误104588 - 在某些情况下无法读取控制台输出

  1. Bug 19850 - Large string printed in Console overstrikes/disappears depending on length
  2. Bug 44866 - Truncate long strings in variables view
  3. Bug 104588 - Unreadable console output under certain conditions

一切似乎都是由于: 错误11601 - 控制台在显示不含crlf的长字符串时挂起

Everything seems to have been a consequence of: Bug 11601 - console hangs while displaying long strings without crlf

这篇关于Windows下的Java控制台错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆