请告知为什么这不起作用,我相信您可以弄清楚我在这里想做什么:
while (socketChannel.read(buffer) > 0) {
buffer.flip();
fileChannel.write(buffer);
buffer.clear();
bigDecimal = bigDecimal.add(kilobyteDecimal);
System.out.print("\\ \r"+"| \r"+"/ \r"+"-- \r");
}
期望看到旋转字符,但相反,我在每个打印语句中都得到了一个新行。
非常感谢
最佳答案
我已经成功地做到了我想要的,尽管代码需要稍微改变一下,但这正是我想要的,并且它按预期工作:
public class ProgressDial {
public static void main(String[] args) throws InterruptedException {
if (args[0].equals("false")) {
System.out.println("Args = false");
System.exit(0);
} else {
while (args[0].equals("true")) {
System.out.print("\\");
Thread.sleep(500);
System.out.print("\b ");
System.out.print("\r");
System.out.print("|");
Thread.sleep(500);
System.out.print("\b ");
System.out.print("\r");
System.out.print("/");
Thread.sleep(500);
System.out.print("\b ");
System.out.print("\r");
System.out.print("-");
Thread.sleep(500);
System.out.print("\b ");
System.out.print("\r");
}
}
}
}
感谢所有给我建议和想法的人。
关于java\r 字符在 Eclipse 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39658283/