Eclipse Hanging on Scanner File Redirection (java) -


i working on program involved taking input stdin intention of having input redirected file. method of doing use scanner class read line, , perform string operation.

i doing in eclipse neon. using run configurations > common > input file option automate redirection on running program , letting output print console.

what finding every time run program, code hangs on last line of file, , not terminate until signal eof ctrl+z (windows). went , opened old projects , noticed same trend , confident didn't have problem before , haven't changed code. below code example:

import java.util.scanner;  public class main {  public static void main(string[] args) {     scanner sc = new scanner(system.in);      string s;     string = "";      while(sc.hasnextline()){         s = sc.nextline();         everything.concat(s);         system.out.println(s);     }     system.out.println(everything);      sc.close();  }} 

it seems hasnextline() blocking waits input, terminate prints final line of file , never prints 'everything'.

example input file im using looks like:

    1     2     3     4 

the program prints 1, 2, 3 on separate lines, not print 4 until signal eof. understanding of hasnextline() when redirected, should recognize eof , stop blocking.

edit: problem seems independent of hasnextline() blocking redirecting file. hasnextline() should not block on file redirection file should signal eof. problem seems related eclipse.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -