用于控制台应用程序的Java gotoxy(x,y)
问题描述:
我正在用Java编写一个简单的控制台应用程序(80x24),是否有gotoxy(x,y)等价物?
I'm writing a simple console application (80x24) in Java, is there a gotoxy(x,y) equivalent?
答
如果通过gotoxy(x,y),您想将光标重新定位在控制台上特定的位置,通常可以使用VT100控制代码来执行此操作。请参见 http://www.termsys.demon.co.uk/vtansi.htm。
If by gotoxy(x,y), you want to reposition your cursor somewhere specific on the console, you can usually use VT100 control codes to do this. See http://www.termsys.demon.co.uk/vtansi.htm.
做类似的事情
char escCode = 0x1B;
int row = 10; int column = 10;
System.out.print(String.format("%c[%d;%df",escCode,row,column));
应将光标移动到控制台上的位置10,10。
Which should move the cursor to position 10,10 on the console.