Hello guys,
I have a problem with this while loop to get it read every line in the text file. Now it read one and skips one,
basically reads odd lines, skips even ones. I want to read every line in the file.
I use it to insert data in a table in a database.
FileInputStream fstream = new FileInputStream("nations.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
String delimiter = ",";
StringTokenizer st = new StringTokenizer(strLine,delimiter);
String code = st.nextToken();
String name = st.nextToken();
stmt.executeUpdate("INSERT INTO nat VALUES('"+ code +"'"+delimiter+"'"+ name +"')");
// read the next line
strLine = br.readLine();
}
//Close the input stream
in.close();
Any help will be greatly appreciated.
Thank you in advance.