Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move printing position of Command Line Interface in Java without using External library

In C, I recalled that I can move the invisible caret around the command line interface screen with respect to the line and character position, meaning I can make the program print any text anywhere on the screen. Do we have such command in Java?

For instance, here is a pseudocode in C:

int main(){
    printf("launching program\n");
    moveTo(4,3); //move to line 4 at character index 3 on the screen.
    printf("AAA");
    moveTo(3,0); //move to line 3 at character index 0 on the screen.
    printf("BBB");
    moveTo(2,1); //move to line 2 at character index 1 on the screen.
    printf("CCC");
    return 0;
}

This will give the following output in the command line interface:

launching program

 CCC
BBB
    AAA

Do we have an equivalent method in Java without using any external or third party library in this case?

like image 671
Karl Avatar asked Sep 19 '26 14:09

Karl


1 Answers

JCurses (Java port of ncurses library from C) is one possibility

like image 74
DVK Avatar answered Sep 21 '26 05:09

DVK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!