Esc [2J如何在Java中实现这一点?

时间:2018-05-21 11:45:26

标签: java escaping

注意:我需要在控制台中清除以前的打印值,并且需要将光标定位在[row] [column] = 0

System.out.println("Hello World");
System.out.println("Hello Country");
System.out.println("\033[0;0H"); //need to apply the escape sequence here
System.out.println("Happy:)");

预期产出:

Happy:)
Hello Country

我在此online compiler中获得此输出但在其他编译器中没有

1 个答案:

答案 0 :(得分:-1)

要获得下一行,只需添加" \ n":

System.out.println("\nHello World");
System.out.println("\nHello Country");
System.out.println("\nEsc[2J"); //need to apply the escape sequence here
System.out.println("\nHappy:)");