Do you want to do this from within a Java class? On the command line?
Originally posted by Deep Narsay:
Suggestion 1 by Ernest might work, but it is not efficient since it will act character by character.
Sorry, no, not at all. All that UNIX "clear" does is send a single ANSI escape sequence -- a few characters -- to the terminal. You can do the same thing by sending the correct characters to your terminal (i.e., printing them.)
Invoking "clear" using Runtime.exec() works only if you also read the output of the process (those magic characters) and print them to System.out. Rather than starting a whole separate process, it's vastly more efficient just to print those few characters, wouldn't you say?
Note that the FAQ Marilyn points to gives the "print blank lines" solution.
Please don't contradict people who know what they're saying with your own wild-ass guesses. I've had way too much of that today already.