如何清除 Java 控制台?
我在 Java 上显示输出消息console 用于使用 webstart 启动的应用程序。 有没有一种方法可以在代码中清除控制台消息,而不是用户手动清除消息?
这些消息以每秒大约 1000 条的速度打印,似乎最终使用了太多内存,我本可以停止打印到控制台,但要求是始终拥有它。
I have output messages displayed on the Java console for an application that started using webstart. Instead of the user manually clearing message, is there a way of clearing console messages in code?
These messages are printed at the rate of about 1000 per second and seem to end up using too much memory, i could have stopped the printing to console, but the requirement is to always have it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将无法清除该控制台,除非您找到该控制台的类的一些句柄(我怀疑您是否有权访问)。
您的要求不可避免地要求用户需要每隔几分钟进入并手动清除控制台。
我认为这有理由重新思考为什么存在该要求以及是否有其他解决方案来解决您的问题。
您是否考虑过采用不同的记录方式?
You will not be able to clear that console, unless you find some handle on the classes for that console (which I doubt you would have access to).
The requirement you have has the inevitable requirement that the user will need to go in and manually clear the console every couple of minutes.
I think that justifies a rethink about why the requirement exists and wether there is another solution to solve your problem.
Have you considered a different way of logging?
在我看来,这个要求应该重新讨论。 如果这不是替代方案,那么您可以限制输出量,因为 1000 条消息/秒对我来说似乎太多了。
我不知道您是否可以以编程方式清除控制台。
Seems to me the requirement should be rediscussed. If this isn't an alternative then you may limit the amount of output, because a 1000 messages/s seems an awful lot to me.
I don't know if you even can programmatically clear the console.