由于某些奇怪的原因,我的\r
不起作用。它不会回到行首:
char[] animationChars = new char[] {'|', '/', '-', '\\'};
public Main() {
for (int i = 0; i < 100; i++) {
System.out.print("Processing: " + i + "% " + animationChars[i % 4] + '\r');
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
输出:
Processing: 0% |
Processing: 1% /
Processing: 2% -
Processing: 3% \
Processing: 4% |
Processing: 5% /
Processing: 6% -
Processing: 7% \
Processing: 8% |
Processing: 9% /
Processing: 10% -
Processing: 11% \
Processing: 12% |
Processing: 13% /
Processing: 14% -
Processing: 15% \
Processing: 16% |
Processing: 17% /