I'm trying to read multiple lines of a txt file in Java and I can't figure out how to get it to read the next line. I've tried a while loop and when I run my program nothing comes out. What I did was a while (line != null) {
so it could read the next line but I've had no luck getting it to complete the task.
This is how the text file reads
20141003 20131105 19990205 20080304,20080305,20080306 19990206,hello,20141001,200003 20050505 July November,August 19640503 19980707 19642199 20141013
import java.util.*;
public class Tokens1 {
public static TextFileInput myFile;
public static StringTokenizer myTokens;
public static String[] list;
public static String line;
public static void main(String[] args) {
myFile = new TextFileInput("project1.txt");
line = myFile.readLine();
myTokens = new StringTokenizer(line, ",");
list = new String[myTokens.countTokens()];
int i = 0;
while (myTokens.hasMoreTokens()) {
list[i] = myTokens.nextToken();
i++;
}
for (int j = 0; j < list.length; j++)
System.out.println(list[j]);
}
}