在控制台上的Windows上的java中打印回车 [英] Print a carriage return in java on windows on console
本文介绍了在控制台上的Windows上的java中打印回车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的OS X机器上,以下行为我提供了一种跟踪循环状态的简单方法:
On my OS X machine, the following line gives me a nice and easy way to track the state of my loops:
for (int index = 0; index < 100; index++)
for (int subIndex = index; subIndex < 100; subIndex++)
System.out.print("\r" + index + "/" + subIndex + " ");
但是当我尝试在Windows上运行相同的东西时,它打印出换行符而不是回车符。如何在Windows上实现跟踪进程的简单方法?
But when I try to run the same thing on windows, it prints out newlines instead of a carriage return. How can I achieve the same simple method of tracking the process on windows?
推荐答案
我有了声明并且在命令中有效提示
I had the statement and it worked in the command prompt
System.out.println("This is Java"+'\r'+"That");
并输出为
That is Java
这意味着它完美无缺。
注意:我在Windows 7中使用JDK 7和简单的记事本运行它。
Note: I run it in Windows 7 with JDK 7 and simple notepad.
这是eclipse的问题,它会将\ r作为新行字符并打印
It is the problem of eclipse, it will take \r as a new line character and will print
This is Java
That
作为输出
这篇关于在控制台上的Windows上的java中打印回车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文