commands in java to clear the screen

后端 未结 11 873
一向
一向 2020-11-29 07:35

What command in Java will let you clear the console in a command-line application?

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 08:16

    I think what the OP wants is to clear the screen and move the cursor to the home position. For that try:

            final String ANSI_CLS = "\u001b[2J";
            final String ANSI_HOME = "\u001b[H";
            System.out.print(ANSI_CLS + ANSI_HOME);
            System.out.flush();
    

提交回复
热议问题