Java: Clear the console

后端 未结 14 2978
青春惊慌失措
青春惊慌失措 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:11

    You can use following code to clear command line console:

    public static void clearScreen() {  
        System.out.print("\033[H\033[2J");  
        System.out.flush();  
    }  
    

    For further references visit: http://techno-terminal.blogspot.in/2014/12/clear-command-line-console-and-bold.html

提交回复
热议问题