Scanner line separator not working with intellij IDEA

this is my code:

public static void main(String[] args) {
    System.out.println("Insert number:");
    int read = creaScanner().nextInt();
    System.out.println("I read "+read);
}

private static Scanner creaScanner() {
    Scanner s = new Scanner(System.in);
    s.useDelimiter(System.getProperty("line.separator"));
    return s;
}

When i run it and type an int and hit enter it just takes me to the next line and displays nothing. Without the line

s.useDelimiter(System.getProperty("line.separator"));

everything works just fine, but this code worked on Eclipse, so i wanted to know if i have to change some settings to make it work on Intellij.

Thanks you in advance

PS

My question is different from this one ( How do I use a delimiter in Java Scanner? ) because i already know how to use scanner and this code runs correctly in Eclipse, but not in intellij. So i was wondering if there's some settings to change to make it work also on intellij. (I am not allowed to change that part of the code, so the answer i am looking for is probably about an intellij setting).

链接地址: http://www.djcxy.com/p/78356.html

上一篇: 调用扫描仪方法而不使用读取内容不好?

下一篇: 扫描仪行分隔符不适用于intellij IDEA