java - Scanner HasNextLine always returns false -


i'm facing weird problem scanner.hasnextline(). i'm not used scanner class i'm used use scanner.hasnextline() condition loop continuously user's input in part of code returns false !

public static void main(string[] args) throws ioexception {     string s = "";     scanner ssc = new scanner(system.in);     client cli = new client();     cli.hlo();     thread t = new thread(new threadmessage(cli));//thread asks user input using scanner , closing     t.start();     boolean b = ssc.hasnextline();     while (true) {         b = ssc.hasnextline();         system.out.println(b);         if (b) {             s = ssc.nextline();             system.out.println("you wrote" + s);             cli.dp.setdata(s.getbytes());             cli.ds.send(cli.dp);         }     } } 

and input have loop of lines word false

does have idea why behaves so?

edit: seems errors comes froms hlo function uses scanner removed , words now.

try use .hasnext() method instead of using .hasnextline() method.
having problems because .hasnextline() method returns true if there line in input of scanner. .hasnext() method returns true if scanner has token in input.

refer : http://docs.oracle.com/javase/7/docs/api/java/util/scanner.html


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -