File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes System.out updating line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "System.out updating line" Watch "System.out updating line" New topic
Author

System.out updating line

Martin Gilday
Greenhorn

Joined: Jul 27, 2005
Posts: 4
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Martin Gilday
Greenhorn

Joined: Jul 27, 2005
Posts: 4
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

Joined: Jul 27, 2005
Posts: 4
Apologies. Seems that Eclipse cannot print backspace. Works perfectly from a terminal.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.out updating line
 
Similar Threads
adding new lines to TextArea form value
conversion of html to java
JTextArea
accessing buffer to transfer data
So where is the Jobless Recovery?