Java: Updating text in the command-line without a new line
问题 I'd like to add a progress indicator to a command-line Java program. For example, if I'm using wget, it shows: 71% [===========================> ] 358,756,352 51.2M/s eta 3s Is it possible to have a progress indicator that updates without adding a new line to the bottom? Thanks. 回答1: First when you write, don't use writeln(). Use write(). Second, you can use a "\r" to Carriage Return without using \n which is a New line. The carriage return should put you back at the beginning of the line.