Is there any way to clear the screen in a console app? I noticed that System does not even appear to have a system call similar to the system("COMMAND"); of C++. Any ideas?

Recommended Answers

All 4 Replies

You don't own the console, and should NEVER assume that you do.
Therefore you should NEVER try to clear it and should NEVER assume that no other process writes to it.

There is no direct way to "clear the screen" (except printing out a bunch of blank lines), and yes there is something to the effect of system("COMMAND");

Check out the Runtime and/or ProcessBuilder classes.

But the advice by jwenting is correct.

Ok thanks! I'll check the Runtime class.. a little more research brought that up too. I'm used to C++ where writing to the console isn't so bad haha

It's just as bad in C++ to assume you own the console.

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.