Re: Modification of output
- From: Roland <roland@xxxxxxxxx>
- Date: Sun, 29 May 2005 13:21:37 +0200
On 29-5-2005 11:38, Mikl wrote:
Hi
Right now I'm using the good ol' System.out.Println to print out to the screen, whenever a certain variable changes. If it changes a lot, it uses up an awful lot of lines though. Is there a way to reuse the same line to that output so whenever it changes, it'll just overwrite the same line?
I'm not using GUI and there are no other Println's in between the above mentioned.
/Mikkel
If your terminal (DOS window/Linux terminal/etc.) supports it, you can use the carriage return character '\r' to bring the "cursor" back to the start of the line. However, if the terminal has scrolled a line (because the output didn't fit on /one/ terminal line), it does not get you to where the System-out-ed line started.
public class TerminalOut
{
public static void main(String[] args) throws InterruptedException {
for (int i = 0; i < 100; i++) {
System.out.print(i);
System.out.print('\r');
Thread.sleep(400);
}
}
}
-- Regards,
Roland de Ruiter ___ ___ /__/ w_/ /__/ / \ /_/ / \ .
- References:
- Modification of output
- From: Mikl
- Modification of output
- Prev by Date: Re: ClassCastException when it should work anyway
- Next by Date: Re: Help with Java servlet : getServletContext().
- Previous by thread: Re: Modification of output
- Next by thread: Help with this JMF problem needed!
- Index(es):