useDelimiter(System.lineSeparator()) not working (but works on Eclipe)

Answered

Hi guys, my code is the following:

    

Scanner s = new Scanner(System.in);
s.useDelimiter(System.lineSeparator());

When i run it and type an int and hit enter it just takes me to the next line and displays nothing. While it runs correctly on the same version of windows (W10) with Eclipse. If i replace it with:

    

Scanner s = new Scanner(System.in);
s.useDelimiter("\n");

It works for me (Intellij) but doesn't work for my colleague on Eclipse.

Both (me and my colleague) are using the same version of Windows.

How can i solve this? Is it a intellij setting that i have to change?

 

Thank you in advance and sorry for my bad english.

0
2 comments

IntelliJ IDEA console is not a real terminal/command line. The behavior of IDEA console can be different when working with command line input.

You can try something like:

s.useDelimiter(System.lineSeparator() + "|\n");
0
Avatar
Permanently deleted user

Thank you a lot! This worked!

0

Please sign in to leave a comment.