I have a text file in my computer which I am reading form my java program, I want to build some criteria. Here is my Notepad File :
#Students
#studentId studentkey yearLevel studentName token
358314 432731243 12 Adrian Afg56
358297 432730131 12 Armstrong YUY89
358341 432737489 12 Atkins JK671
#Teachers
#teacherId teacherkey yearLevel teacherName token
358314 432731243 12 Adrian N7ACD
358297 432730131 12 Armstrong EY2C
358341 432737489 12 Atkins F4NGH
when I read from this note pad file, I get the exact data as it is in my application but I want to read only the token column inside students and put them in my array named studentTokens. Here is the code
public static void main(String[] args) {
ArrayList<String > studentTokens = new ArrayList<String>();
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("c:/work/data1.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}