I need to clear the output console buffer from within java on a windows console. I was thinking of a batch call to "cls" how can this be achieved?

public static void cls(){
//clear the screen pretty please!
}

The Runtime and Process classes can be used to call external/OS commands.

I personally have tried

Runtime.getRuntime().exec("command.com /c cls");
System.out.print("\f");
System.out.print("\033[2J\033[H");

ALL of which did not work on Windows XP.

Also, check out the answers here: http://www.daniweb.com/software-development/java/threads/381318

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.