ok so i want to read a .txt file line by line. I have the code for that BUT i want to keep track of what line im on, i might be completely braindead from working on this whole project forever but heres the line by line code i am using.
// all the code for reading and parsing .txt file and setting up survey (loading)
File file = new File(txtFile + ".txt");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
// Here BufferedInputStream is added for fast reading.
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
// dis.available() returns 0 if the file does not have more lines.
while (dis.available() != 0) {
// this statement reads the line from the file and parses them
dis.readLine();
}
// dispose all the resources after using them.
fis.close();
bis.close();
dis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
is there a way I can keep a line counter because like the way my program is set up, certain lines mean different things to me. I need to use conditions on a lot of the lines, some depending on the number of the line and some depending on what a key word of a line says.