1. How do you clear the screen in a console java app?

2. How do you input text in the console area? Is it something with System.in?

...There may be more later :-P

  1. I've never done this so I'm not too clear on this. I think you have to set some kind of system property and then you can get properties of the console, and use escape sequences to clear console.

    public class Hello
         {
                 public static void main(String[] args)
                 {
                         System.out.println("Hello");
                  }
          }
    

lol this question was posted like half a year ago, but ohh welll.

Edited 3 Years Ago by pyTony: fixed formating

Console applications should never clear the screen. They should not even assume they have sole control over the screen below the point they're started from (for example, another application running in the background may well interrupt them to write something to the output itself, this could be the JVM writing some error message for example).

Hi everyone,

The simple answer is you can't but you can do this, it's a rather stupid way but it works

void public clear () 
{
int i = 0;

for(i=0;i<300;i++)
{
System.out.println("\n");
}

}

It does the trick for me

I hope this helped you

By the way do you know how to print the contents of a JTextPane??

Yours Sincerely

Richard West

This article has been dead for over six months. Start a new discussion instead.