0

Hi,

I would like to know the code used for java to clear the screen as we do in c# using Console.clear(); is it possible in Java aswell? If yes, what code should i use?

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by Taywin
0

It isn't possible in Java.

A workaround would be to create 20 or so white lines, or how many you see fit.

0

As Aviras said, there is no real clear screen in Java. Supposed you are doing it on a console, if you want, you could try...

System.out.println("\u001b[2J");

That should have an effect similar to clear() but not exactly the same.

0

It doesn't clear the console but it will automatically add new lines to the console until your command line is at the bottom of the console display. Normally, you would see that all of other contents are gone from the display. You may try it?

Edited by Taywin: n/a

0

but it will automatically add new lines to the console until your command line is at the bottom of the console display. Normally, you would see that all of other contents are gone from the display.

Could you make it more clear . I cant understand what you are trying to say.

u001b[2J . What does it do ?

It will be nice if you explain with small program..

0

Hmm... Just tested on Window box and it seems to not work as I expected... On Linux, it works fine... I am sorry. Need to look further into this thing...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.