问题
So what I am trying to do it so simulate clearing screen of Eclipse terminal.
I know there isn't a real solution for clearing the screen so I know I must use tons of empty lines to clear the screen.
The problem is that when I do tons of new line characters the pointer would be at the bottom of the terminal.
How would I do this so I would end up with pointer at the top of terminal and entire view would appear clear of any text?
So it would look like Aircrack-ng like interface. The screen keep changing but only by scrolling down and updating the content, etc.
回答1:
What you want basically is to emulate the clrtobot curses function. Which:
erase from the cursor to the end of screen. That is, they erase all lines below the cursor in the window. Also, the current line to the right of the cursor, inclusive, is erased.
In window$, there's the "cls" function, so you must use something like
Runtime.getRuntime().exec("cls");
In most *nix there's the "clear" function. But please don't rely too much on this solution, because this varies, but you can use something like:
Runtime.getRuntime().exec("clear");
I'm yet to see a solution non OS dependent.
I hope it helped. Cheers
来源:https://stackoverflow.com/questions/13504717/how-to-redraw-the-console-screen-so-it-would-appear-as-screen-was-cleared