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
Post a Comment