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

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

问题描述

以下代码

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 下的 java 控制台上的开始"和结束"之间产生一个空行,但在运行 MacOS 或 Linux 时按预期工作.在写入文件而不是使用 sysout 时同样适用.我试过多台windows机器.不管我是通过eclipse还是通过cmd执行方法.

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 个字符.所以这是一个已知的错误.

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.

解决方法是转到 Workspace->Preferences->Run/Debug->Console 并将固定宽度控制台设置为 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) 和 Indigo (3.7),都表现出这种行为,但奇怪的是,Galileo &正如 OP 所说,Helios 有一个限制 = 818(4090 个字符)和 Indigo = 936(4680)个字符.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. Bug 19850 - 控制台中打印的大字符串会根据长度覆盖/消失
  2. 错误 44866 - 在变量视图中截断长字符串
  3. 错误 104588 - 在某些情况下无法读取控制台输出

一切似乎都是由于:Bug 11601 - 控制台在显示时挂起没有crlf的长字符串

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

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