Clearing the console in Kotlin

Viewed 5878

When using the usual Runtime.getRuntime().exec("clear") as you would in Java, nothing happens. However, if instead use touch test.txt a text file is indeed created. Is there a reason for this, and if so, are there any alternatives?

Both work in Java in the same environment.

EDIT: Missed brackets

1 Answers

You need to call print("\u001b[H\u001b[2J"), using an escape sequence, at least on Linux.

Related