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

折月煮酒 提交于 2019-11-26 14:36:53

问题


If I

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

at console, I have cursor back at the beginning of line, and finally after

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

I have

 anything

typed.

But at Eclipse console I get

something
 anything

as if it treated \r as CR/LF.

How can I setup this?


回答1:


As Nishant already pointed out in the comments, you've found a bug here.

This bug initially was reported in 2004 (>9 years ago!?!!) and this bug seems not to be fixed very soon (or ever). I tested it on several Eclipse version, even on Eclipse Juno SR2, and the bug is still there.




回答2:


It finally seems to be fixed in Mars!

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

Your code

public class Main {

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

Output

 anything


来源:https://stackoverflow.com/questions/14792478/how-to-get-carriage-return-without-line-feed-effect-in-eclipse-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!