在Windows / Java中反向换行 [英] Reverse line feed in Windows / Java

查看:212
本文介绍了在Windows / Java中反向换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Windows中向系统控制台写几行,然后使用Java删除或修改它们?我可以使用 \r 回车字符在同一行多次写入。 Cygwin命令 less (一个文本查看器)管理它(虽然它不是Java),所以我怀疑是可能的。

Is there a way to write several lines to the system console in Windows, then delete or modify them, using Java? I can write over the same line more than once using the \r carriage return character. The Cygwin command less (a text viewer) manages it (although it's not Java), so I suspect it's possible.

我试过 \\\ 这是(根据我googled的页面)反向换行字符,但它似乎不工作。

I've tried \u008D which is (according to a page I googled) the reverse line feed character, but it doesn't seem to work.

    System.out.println("1");
    System.out.println("2");
    System.out.print("\u008D");
    System.out.println("3");

输出

1
2
?3

看到

1
3


推荐答案

JLine 图书馆可以提供更高级的控制台控制,没有其他工作。请注意,它使用本机代码。

The JLine library can give more advanced console control when nothing else works. Be aware that it uses native code.

killLine()方法可能是你之后如果你最终使用JLine。

The killLine() method may be what you are after if you end up using JLine.

这篇关于在Windows / Java中反向换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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