I\'m writing a simple program in Java and it requires reading data from a text file. However, I\'m having trouble counting lines. The issue seems generic enough for a simple
inFile.hasNext() does not move the pointer to the next line
try this
String x=null;
while((x = inFile.next()) != null)
count++;
description of hasNext()
Returns true if this scanner has another token in its input. This method may block while waiting for input to scan. The scanner does not advance past any input.
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html#hasNext%28%29