So Im working of reading a file containing appointments that I wrote to earlier in my code. I want to sift through the text file and find appointments on a certain date and
pl try this
you r using "read = in.readLine())" two times in while loop that why it is skiping the lomes
public ArrayList read(int checkDay, int checkMonth, int checkYear) {
ArrayList events = new ArrayList();
BufferedReader in = null;
String read;
try {
in = new BufferedReader(new FileReader("calendar.txt"));
while ((read = in.readLine()) != null) {
String[] split = read.split(",");
System.out.println(read);
if (split[0].equals(Integer.toString(checkDay)) && split[1].equals(Integer.toString(checkMonth)) && split[2].equals(Integer.toString(checkYear))) {
events.add(split[0] + " : " + split[1] + "/" + split[2] + "/" + split[3]);
}
}
} catch (IOException e) {
System.out.println("There was a problem: " + e);
e.printStackTrace();
} finally {
try {
in.close();
} catch (Exception e) {
}
}
return events;