Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How do you clear console screen in Java?
If there is no neat function for that , then how do you position cursor in the given position in console screen.Thanx in advance

Google really does work!
Try this query. The first two results answer both your questions, and if that's not quite what you're looking for I bet it's in another result.

NO s--- MAN IT WORKS!
If I have found the answer in Google I wouldnt be asking it here. So if its too hard for you too answer dont bother replying like that. I visited those sites and I have no clue what does it say there. I suck at java and I asked it here because I hoped to get clearlier answer.

NO s--- MAN IT WORKS!
I'm glad to see we're in agreement!
...I asked it here because I hoped to get clearlier answer.
An easy way to clear the console, which will work regardless of the platform is to simply "brute force" it:
for (int i=0; i<15; i++)
System.out.println("\n");The only issue you might have is how many newlines to print, but printing is "cheap" enough that it's not a big deal. It is a lot less expensive though to print multiple newlines inside each print statement rather than calling println() many times (ie: double the number of '\n's and cut the number of loop iterations in half for better performance).
As far as placing the cursor at a specific place, dunno about that. Setting a horizontal position is easy enough, but I don't know about a vertical one that's platform independent and doesn't involve clearing the screen.

Thanx man,
I figured the way you are describing my self though. And its not how I want it though. I actually want everything to desappear from console rather then move up... Thats why I wanted to know how to move cursor to a given postion so I can move it up and system.out.println() over the other stuff. But well I can see its a big problem in Java and it doesnt matter now anyways.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |