• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out updating line

 
Martin Gilday
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is probably really simple but I have never come across it before.
I am writing a transfer app and want to log progress back to the terminal. What I want to have is basically "Transfer: 50 of 600231". But I dont want to have a new line printed each time, just update the previous one. I know this is possible as Maven does this, when deploying and downloading. I had a look through the source but it is too vast to find where it is.

Is it possible to do this with some sort of Printer or are there any existing libs for doing this?

Thanks.
 
Joe Ess
Bartender
Posts: 9295
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The backspace character is 0x08. Print out the same number of backspaces as characters you've printed out. You could also probably use the carrage return character (0x0d), but I've never tried it.
 
Martin Gilday
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.
I have tried this System.out.print((char)0x08);
But I simply get a rectangle printed instead.
 
Martin Gilday
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies. Seems that Eclipse cannot print backspace. Works perfectly from a terminal.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic