Java Scanner isn't reading my txt file -
i tad frustrated because simple giving me problems. it's been while since fired java i'm pretty sure i've done right. here code:
import java.util.scanner; public class driver { public static void main(string[] args){ scanner input = new scanner("numbers.txt"); while(input.hasnext()){ system.out.println(input.nextint()); } } }
i tried moving file src folder. tried pointing scanner file c://sample.txt
didn't work either.
i'd appreciate tips.
the scanner(string)
constructor points scanner
@ contents of string -- string doesn't represent filename. can use new scanner(new file("numbers.txt"))
.
Comments
Post a Comment