I'm writing a simple console application (80x24) in Java, is there a gotoxy(x,y) equivalent?
public void putString(java.lang.String s) Places a String on the screen starting at the current screen cursor location. To place a string at a specific location use the gotoXY() method to set the cursor, or use the putStringAt() method.
To clear the console in Java, we will use the escape code \033[H\033[2J . This weird set of characters represents the command to clean the console.
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.
Do something like
char escCode = 0x1B; int row = 10; int column = 10; System.out.print(String.format("%c[%d;%df",escCode,row,column));
Which should move the cursor to position 10,10 on the console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With