javainputtext-cursor

How to put input cursor after prompt java


I tried to emulate console dialog using java. The code is simple:

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        String s;
        Scanner in = new Scanner(System.in);
        do {
            System.out.print(">>>");
            s = in.next();
            System.out.println(s);
        } while ( !new String("exit").equals(s));
     }
}

But when it works it puts cursor in the begining of line, not after prompt (">>>" in this case).
Is there any way to place cursor after the prompt? (Here is brief video to show what I mean https://youtu.be/6QA6849hR9A)


Solution

  • It is a problem with IDE. When this code runs with cmd it works well. https://youtu.be/BpIcJbUI7MM