Groovy Console read input

后端 未结 5 668
闹比i
闹比i 2021-02-01 05:27

I\'m just starting to learn Groovy and I am experimenting in GroovyConsole.

Is there a way I can read user input? I have tried the code below but I get an error.

5条回答
  •  广开言路
    2021-02-01 05:44

    if your System.console() is null, you can

    Scanner scan = new Scanner(System.in);
    String s = scan.nextLine()
    

提交回复
热议问题