Java: Clear the console

后端 未结 14 2687
青春惊慌失措
青春惊慌失措 2020-11-21 23:26

Can any body please tell me what code is used for clear screen in Java? For example in C++

system(\"CLS\");

What code is used in Java for

14条回答
  •  醉梦人生
    2020-11-22 00:22

    You need to use control characters as backslash (\b) and carriage return (\r). It come disabled by default, but the Console view can interpret these controls.

    Windows>Preferences and Run/Debug > Console and select Interpret ASCII control characteres to enabled it

    After these configurations, you can manage your console with control characters like:

    \t - tab.

    \b - backspace (a step backward in the text or deletion of a single character).

    \n - new line.

    \r - carriage return. ()

    \f - form feed.

    More information at: https://www.eclipse.org/eclipse/news/4.14/platform.php

提交回复
热议问题