Java 中的“\b” - Windows 实现

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3200375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:20:52  来源:igfitidea点击:

"\b" in Java - Windows implemented

javabackspace

提问by Angad

Working on Java in a Windows-run computer lab.

在 Windows 运行的计算机实验室中研究 Java。

System.out.print ("Hello!");
System.out.print ("\b");

Prints

印刷

Hello![]

你好![]

Where [] is a box, so as to signify a character the font doesn't support, or has an invalid ASCII value or something.

其中 [] 是一个框,以表示字体不支持的字符,或具有无效的 ASCII 值或其他内容。

This is something pretty primitive, and comes in handy to make fancy looking terminal applications, so please help me out :)

这是一个非常原始的东西,可以派上用场来制作漂亮的终端应用程序,所以请帮帮我:)

采纳答案by Brian S

I don't know about Eclipse's failures (god knows I've pulled enough hair out trying to fix issues my coworker gets using Eclipse), but could you manage with using the [home] character?

我不知道 Eclipse 的失败(天知道我已经为解决我的同事在使用 Eclipse 时遇到的问题付出了足够的努力),但是您能使用 [home] 字符进行管理吗?

System.out.print("Hello!" + (char)13);
System.out.print("      ");
System.out.print("Hello");

It's a kludge compared to \bfor your purpose, but if the output you're using doesn't work with one control character, try another! :)

\b您的目的相比,这是一个混乱,但如果您使用的输出不适用于一个控制字符,请尝试另一个!:)

回答by BalusC

This problem indeed occurs in at least Eclipse's console, but certainly not in Windows command console.

这个问题确实发生在至少 Eclipse 的控制台中,但肯定不会出现在 Windows 命令控制台中。

Also see this related topic: How to get backspace \b to work in Eclipse's console?

另请参阅此相关主题:How to get backspace \b to work in Eclipse's console?