繁体   English   中英

如何在 Eclipse 控制台中获得没有换行效果的回车?

[英]How to get carriage return without line feed effect in Eclipse console?

如果我

System.out.print("something\r");

在控制台,我的光标回到行首,最后在

System.out.print("something\r");
System.out.print(" any\r");

我有

 anything

打字。

但是在 Eclipse 控制台我得到

something
 anything

好像它将\\r视为 CR/LF。

我该如何设置?

正如 Nishant 已经在评论中指出的那样,您在这里发现了一个错误

这个错误最初是在 2004 年(> 9 年前!?!!)报告的,这个错误似乎不会很快(或永远)修复 我在几个 Eclipse 版本上测试过它,甚至在Eclipse Juno SR2 上,错误仍然存​​在。

该错误现已修复(Eclipse 2020-03)。 就去

Window ➺ Preferences ➺ Run/Debug ➺ Console

并确保两个复选框

Interpret ASCII control characters

Interpret Carriage Return (\r) as control character

已启用。

好像终于在火星上修好了!

Version: Mars Release (4.5.0)
Build id: 20150621-1200
Used Java: jre1.8.0_60

你的代码

public class Main {

    public static void main(String[] args) {
        System.out.print("something\r");
        System.out.print(" any\r");
    }
}

输出

 anything

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM