如何删除 System.out.println() 打印到控制台的内容? [英] How to delete stuff printed to console by System.out.println()?

查看:52
本文介绍了如何删除 System.out.println() 打印到控制台的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Java 应用程序中,我使用了一些对 System.out.println() 的调用.现在我想找到一种以编程方式删除这些东西的方法.

In a Java application I'm using some calls to System.out.println(). Now I want to find a way to programmatically delete this stuff.

我在谷歌上找不到任何解决方案,所以有什么提示吗?

I couldn't find any solution with google, so are there any hints?

推荐答案

退格符  可以打印与之前打印的字符一样多的次数.

You could print the backspace character  as many times as the characters which were printed before.

System.out.print("hello");
Thread.sleep(1000); // Just to give the user a chance to see "hello".
System.out.print("");
System.out.print("world");

注意:在 Mars (4.5) 之前的旧版本中,这在 Eclipse 控制台中无法完美运行.然而,这在命令控制台中非常有效.另请参阅 如何让退格  在 Eclipse 中工作控制台?

Note: this doesn't work flawlessly in Eclipse console in older releases before Mars (4.5). This works however perfectly fine in command console. See also How to get backspace  to work in Eclipse's console?

这篇关于如何删除 System.out.println() 打印到控制台的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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