import java.util.Scanner;
import java.util.regex.Pattern;
public class dsr {
final static String ESC = "\u001b";
final static String ANSI_PREFIX = ESC + "[";
final static String ANSI_DSR = ANSI_PREFIX + "6n";
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("1234567" + ANSI_DSR);
System.out.println("@" + scan.next(Pattern.compile(".*")));
}
}
This code tries to read the return from the terminal with a scanner, but the return is not captured and is displayed directly. The scanner waits for a keyboard entry. How to retrieve the returned value ^[[5;8R