java - Why would this only print the first line? -


import java.util.scanner;  public class parsethetweet {  public static void main(string[] args) {     // todo auto-generated method stub         scanner thescanner = new scanner(system.in);                      string tweet = "";             system.out.println("enter tweet");         tweet = thescanner.nextline();         system.out.println(tweet);    } } 

this program have far, simple , have feeling i'm doing easy wrong. want output variable tweet same input, keeps printing first line.

ex. input:

#typ offer; #det free essential supplies 4 evacs pets.; #loc 2323    55th st, boulder; #lat 40.022; #lng -105.226;        

output:

 #typ offer; #det free essential supplies 4 evacs pets.; #loc 2323 

if want read more lines one, need call thescanner.nextline() in loop, e.g.:

while (thescanner.hasnextline()) {     string tweet = thescanner.nextline();     system.out.println(tweet); } 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -